Retrieving a list of all of your virtual machines
Now that we know how to connect to a server, let's do something useful with PowerCLI. Most of the people who begin using PowerCLI create reports, so create a list of all of your virtual machines as your first report. You have to use the Get-VM
cmdlet to retrieve a list of your virtual machines. The syntax of the Get-VM
cmdlet is as follows. The first parameter set is the default:
Get-VM [[-Name] <String[]>] [-Server <VIServer[]>]
[-Datastore <StorageResource[]>] [-Location <VIContainer[]>]
[-Tag <Tag[]>] [-NoRecursion] [<CommonParameters>]
The second parameter set is for retrieving virtual machines connected to specific virtual switches:
Get-VM [[-Name] <String[]>] [-Server <VIServer[]>] [-VirtualSwitch ...
Get Learning PowerCLI - Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.