VMware Cloud Community
Gaprofitt17
Enthusiast
Enthusiast
Jump to solution

Assistance with script, actual running OS vs configured

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

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

That is the OS name as determined by the VMware Tools.

Try like this

$report = foreach($vc in $global:DefaultVIServers){

   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

View solution in original post

0 Kudos
3 Replies
LucD
Leadership
Leadership
Jump to solution

That is the OS name as determined by the VMware Tools.

Try like this

$report = foreach($vc in $global:DefaultVIServers){

   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

0 Kudos
Gaprofitt17
Enthusiast
Enthusiast
Jump to solution

Thanks, if I wanted to add allocated memory per VM how would I accomplish that.  Thanks so much..

0 Kudos
LucD
Leadership
Leadership
Jump to solution

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

0 Kudos