Hi
I am wondering if somebody could help me with a script for gathering an inventory of vms by cluster . I would like to list as much information about the vm as possible (cpu number harddrive size,memory, IP Address, datastore stored on, folder list,number of Nic's,port groups.
I started to try to hack at this script but are getting a bit stuck any help would be appreciated
Connect-VIServer XXXXXX
$Cluster = Read-host "enter Cluster name"
$VmInventory = ForEach ($VM in ($Cluster | Get-VM | Sort-Object -Property Name)) {
ForEach ($HardDisk in ($VM | Get-HardDisk | Sort-Object -Property Name)) {
"" | Select-Object -Property @{N="VM";E={$VM.Name}},
@{N="Cluster";E={$Cluster.Name}},
@{N="IP";E={[string]::Join(',',$VM.Guest.IPAddress)}},
@{N="Hard Disk";E={$HardDisk.Name}},
@{N="VMConfigFile";E={$VM.ExtensionData.Config.Files.VmPathName}},
@{N="VMDKpath";E={$HardDisk.FileName}},
@{N="VMDK Size";E={($vm.extensiondata.layoutex.file|?{$_.name -contains $harddisk.filename.replace(".","-flat.")}).size/1GB}}
}
}
$VmInventory | Export-Csv -NoTypeInformation -UseCulture -Path "VmInventory.csv"