Difference between revisions of "Using PowerCLI in Powershell"
From Tech-Wiki
Line 3: | Line 3: | ||
How to use PowerCLI to output VM information for ESXi. | How to use PowerCLI to output VM information for ESXi. | ||
− | Install-Module -Name VMware.PowerCLI | + | PS C:\> Install-Module -Name VMware.PowerCLI |
− | Set-PowerCLIConfiguration -Scope User -ParticipateInCEIP $false | + | PS C:\> Set-PowerCLIConfiguration -Scope User -ParticipateInCEIP $false |
− | Set-PowerCLIConfiguration -InvalidCertificateAction Ignore | + | PS C:\> Set-PowerCLIConfiguration -InvalidCertificateAction Ignore |
− | Connect-VIServer 10.1.1.10 | + | PS C:\> Connect-VIServer 10.1.1.10 |
− | Get-VM | Select Name,PowerState,MemoryGB,NumCpu,UsedSpaceGB | + | PS C:\> Get-VM | Select Name,PowerState,MemoryGB,NumCpu,UsedSpaceGB |
− | Get-Cluster "Test-*" | Get-VM | Sort | Select Name, @{N="IP Address";E={$_.guest.IPAddress[0]}} | export-csv report.csv -NoTypeInformation –UseCulture | + | PS C:\> Get-Cluster "Test-*" | Get-VM | Sort | Select Name, @{N="IP Address";E={$_.guest.IPAddress[0]}} | export-csv report.csv -NoTypeInformation –UseCulture |
− | Get-VM | Get-View -Property @("Name", "Config.GuestFullName", "Guest.GuestFullName") | Select -Property Name, @{N="Running OS";E={$_.Guest.GuestFullName}} | Format-Table -AutoSize | + | PS C:\> Get-VM | Get-View -Property @("Name", "Config.GuestFullName", "Guest.GuestFullName") | Select -Property Name, @{N="Running OS";E={$_.Guest.GuestFullName}} | Format-Table -AutoSize |
+ | |||
+ | Among commands above, hints how to deal with large columns, sorting or exporting to .csv |
Revision as of 17:50, 24 August 2023
How to use PowerCLI to output VM information for ESXi.
PS C:\> Install-Module -Name VMware.PowerCLI PS C:\> Set-PowerCLIConfiguration -Scope User -ParticipateInCEIP $false PS C:\> Set-PowerCLIConfiguration -InvalidCertificateAction Ignore PS C:\> Connect-VIServer 10.1.1.10 PS C:\> Get-VM | Select Name,PowerState,MemoryGB,NumCpu,UsedSpaceGB PS C:\> Get-Cluster "Test-*" | Get-VM | Sort | Select Name, @{N="IP Address";E={$_.guest.IPAddress[0]}} | export-csv report.csv -NoTypeInformation –UseCulture PS C:\> Get-VM | Get-View -Property @("Name", "Config.GuestFullName", "Guest.GuestFullName") | Select -Property Name, @{N="Running OS";E={$_.Guest.GuestFullName}} | Format-Table -AutoSize
Among commands above, hints how to deal with large columns, sorting or exporting to .csv