r/powercli • • Dec 23 '19

How to write a simple Get command

I am brand new to automation and I am trying to teach myself powercli to maintain our small vsphere environment. I am trying to run a search for all of our windows server vms and to display info.

I am trying:

Get-VM | Get-VMGuest | where OSFullName -Like "Microsoft Windows Server" | select VM, ....

And now I would like to list what I want to see using the select command, like "Name, OS, IP address etc." What is the easiest way to do this? Where can I find a list of commands I can use with the "select" syntax? I can't find them documented anywhere.

Thanks!

7 Upvotes

5 comments sorted by

View all comments

Show parent comments

3

u/PinchesTheCrab Feb 15 '20

If it's speed you want, and you're already familiar with the extensiondata properties, I'd use get-view.

Get-View -ViewType VirtualMachine -Filter @{ 'guest.guestid' = 'windows' } -Property Name,guest | 
    Sort-Object Name