Last active
July 20, 2018 01:10
-
-
Save dapacruz/5bb5941cc9b6800dbfbf5103db5f48a0 to your computer and use it in GitHub Desktop.
Get a list of all VMware virtual machines (VMs), including the VMX file location (VM Inventory).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # VMware PowerCLI | |
| # Virtual machine (VM) inventory report | |
| $properties = @( | |
| 'Name' | |
| @{n='HostName';e={$_.ExtensionData.Guest.HostName}} | |
| @{n='IpAddress';e={$_.Guest.IpAddress.where{$_ -match '(\d{1,3}\.){3}\d{1,3}'} -join ', '}} | |
| @{n='GuestFullName';e={$_.ExtensionData.Guest.GuestFullName}} | |
| @{n='ToolsVersion';e={$_.Guest.ToolsVersion}} | |
| @{n='ToolsBuild';e={$_.Guest.VM.ExtensionData.Guest.ToolsVersion}} | |
| @{n='ToolsStatus';e={$_.Guest.VM.ExtensionData.Guest.ToolsStatus}} | |
| @{n='ToolsVersionStatus';e={$_.Guest.VM.ExtensionData.Guest.ToolsVersionStatus}} | |
| @{n='ToolsRunningStatus';e={$_.Guest.VM.ExtensionData.Guest.ToolsRunningStatus}} | |
| @{n='VmVersion';e={$_.Guest.VM.Version}} | |
| 'NumCpu' | |
| 'CoresPerSocket' | |
| 'MemoryGB' | |
| 'ProvisionedSpaceGB' | |
| 'UsedSpaceGB' | |
| 'Notes' | |
| 'PowerState' | |
| 'ResourcePool' | |
| @{n='VmxPath';e={$_.extensiondata.config.files.vmpathname}} | |
| @{n='VmdkPath';e={($_ | Get-HardDisk).Filename -join ', '}} | |
| ) | |
| $params = @{Property = $properties} | |
| $vms = Get-VM | Select-Object @params | |
| $vms | Export-Csv -NoTypeInformation 'VMware Virtual Machine Inventory.csv' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment