Programatically retrieve VM Table information

Programatically retrieve VM Table information

I'm trying to figure out a way via PowerShell, or even the main Prism interface to export all of the table information from the VM > Table space within Prism. Like this.

Doing an entire .CSV export of this would be just fine, but it appears to limit to 1000 rows. I would expect something along the lines of grabbing all the VM's with Get-NTNXVM and piping that into Get-NTNXVMStat, but this cmdlet appears to need several metrics specified that I just can't dig into properly. I receive 500 errors any time I try to retrieve information, and there's no Get-Help / example entries for the cmdlet.

Is there an easy way I'm overlooking to retrieve exactly that formatted table from prism? If not, any canned PS scripts that can do it? The individual I/O statistics are very helpful here, as a whole this is an excellent, granular snapshot of the environment.

Re: Programatically retrieve VM Table information

Thank you! Pretty sure this is what I need, I appreciate it. I'm currently trying to find a way to filter it down right now. This cluster has about 2500 VM's in it, with a 4.5:1 CPU ratio and heavily utilization, I think this is causing the Get-NTNXVM cmdlet to time out. I believe I can accomplish this by importing a .csv with chunks of names of VM's, and then combining the .CSV files later.

Re: Programatically retrieve VM Table information

@mhutchison89 Since you have a large number of vm's i have changed the code to use Object collections instead of normal arrays which will be more memory efficient. The changes are in only two lines, please use the below script,

Re: Programatically retrieve VM Table information

Thanks Chandru, I have a question..

The updated PS code using objects works great if I specify a single VM, like this, where I'm using -searchString to specify a single VM. The .CSV will export perfectly for that VM. As soon as I remove that search criteria the GET-NTNXVM cmdlet will time out within about 15-30 seconds.

Re: Programatically retrieve VM Table information

@mhutchison89 Does it work when you use regular arrays instead of the object colletions? You can try to limit the count of vm returned by Get-NTNXvm using the -Count parameter and check if it is getting output.

I tested it on a 120 vm test cluster didn't receive any timeouts , you can limit to the lesser number and see if it works.

Re: Programatically retrieve VM Table information

Yep, the script runs if I limit the count to < 300. If I could feed the script a list of VM names I could probably get around that limitation. I've tried Get-NTNXVM -count 300 | Where {$_.VMName -like $arrayofnames} but the command times out with that as well, I assume because it's having to crawl the entire inventory again.

Re: Programatically retrieve VM Table information

Yeah, even if I just filter down to the single VMname property, the cmdlet still times out. I've also tried Getting the list of VM names via the API, using the Invoke-RestMethod cmdlet. Like this, but I receive a time out there as well (With or without the timeout flag)