Hi All,
Need some help, I am running the following:
$report = foreach($vc in $global:DefaultVIServers){
Get-VM -Server $vc |
Select @{N='vCenter';E={$vc.Name}},
@{N='VMHost';E={$_.VMHost.Name}},
@{N='VM';E={$_.Name}},
@{N='OS';E={$_.Guest.OSFullName}},
@{N='vCPU';E={$_.NumCpu}},
@{N='CPU sockets';E={$_.NumCpu/$_.ExtensionData.Config.Hardware.NumCoresPerSocket}},
@{N='Cores/socket';E={$_.ExtensionData.Config.Hardware.NumCoresPerSocket}},
PowerState
}
$report | Export-Csv report.csv -NoTypeInformation -UseCulture
Is .Guest.OSFullname the configured and or running OS? I'm looking to capture both configured and running OS. Also how would I add the cluster name for each VM?
Thanks so much,
Greg
That is the OS name as determined by the VMware Tools.
Try like this
Get-VM -Server $vc |
Select @{N='vCenter';E={$vc.Name}},
@{N='Cluster';E={Get-Cluster -VM $_ | Select -ExpandProperty Name}},
@{N='VMHost';E={$_.VMHost.Name}},
@{N='VM';E={$_.Name}},
@{N='ConfiguredOS';E={$_.ExtensionData.Config.GuestID}},
@{N='OS';E={$_.Guest.OSFullName}},
@{N='vCPU';E={$_.NumCpu}},
@{N='CPU sockets';E={$_.NumCpu/$_.ExtensionData.Config.Hardware.NumCoresPerSocket}},
@{N='Cores/socket';E={$_.ExtensionData.Config.Hardware.NumCoresPerSocket}},
PowerState
}
$report | Export-Csv report.csv -NoTypeInformation -UseCulture
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
That is the OS name as determined by the VMware Tools.
Try like this
Get-VM -Server $vc |
Select @{N='vCenter';E={$vc.Name}},
@{N='Cluster';E={Get-Cluster -VM $_ | Select -ExpandProperty Name}},
@{N='VMHost';E={$_.VMHost.Name}},
@{N='VM';E={$_.Name}},
@{N='ConfiguredOS';E={$_.ExtensionData.Config.GuestID}},
@{N='OS';E={$_.Guest.OSFullName}},
@{N='vCPU';E={$_.NumCpu}},
@{N='CPU sockets';E={$_.NumCpu/$_.ExtensionData.Config.Hardware.NumCoresPerSocket}},
@{N='Cores/socket';E={$_.ExtensionData.Config.Hardware.NumCoresPerSocket}},
PowerState
}
$report | Export-Csv report.csv -NoTypeInformation -UseCulture
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks, if I wanted to add allocated memory per VM how would I accomplish that. Thanks so much..
The object returned by Get-VM contains two properties, MemoryMB and MemoryGB.
Just add one of those on the Select cmdlet, similar to PowerState.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference