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:
Get-VM [[-Name] <String[]>] [-Server <VIServer[]>] [-Datastore <StorageResource[]>] [-Location <VIContainer[]>][-Tag <Tag[]>] [-NoRecursion] [<CommonParameters>] Get-VM [[-Name] <String[]>] [-Server <VIServer[]>] [-DistributedSwitch <DistributedSwitch[]>] [-Tag <Tag[]>][<CommonParameters>] Get-VM [-Server <VIServer[]>] -Id <String[]> [<CommonParameters>] Get-VM ...
Get Learning PowerCLI 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.