VMware Cloud Community
mprobst
Contributor
Contributor
Jump to solution

powercli get guest OS version reported by VMware tools versus configured when VM created or edited.

in my inventory scripts and in what RV tools outputs I get the OS version that is selected for the VM in edit settings - options - version.  I would like to also output a list of the OS version that VMware tools is reporting so I can find the ones with wrong OS selected and fix them.  I have tried .extensiondata.config.tools  and I dont see the OS listed there, does anyone know where it is listed?

PowerCLI C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI> $vm1.extensiondata.config.tools

ToolsVersion         : 9354

AfterPowerOn         : True

AfterResume          : True

BeforeGuestStandby   : True

BeforeGuestShutdown  : True

BeforeGuestReboot    :

ToolsUpgradePolicy   : upgradeAtPowerCycle

PendingCustomization :

SyncTimeWithHost     : True

LastInstallInfo      : VMware.Vim.ToolsConfigInfoToolsLastInstallInfo

DynamicType          :

DynamicProperty      :

side note,  where can I find a resource that shows what options are available for each get command, like get-host and get-vm?  I am learning a lot about what I can find in powercli by running this command and exploring the ones that return VMware.Vim......, but would save me a lot of time to be able to just go look it up.

PowerCLI C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI> $vm1 = get-vm test-vm1

PowerCLI C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI> $vm1.extensiondata

Capability           : VMware.Vim.VirtualMachineCapability

Config               : VMware.Vim.VirtualMachineConfigInfo

Layout               : VMware.Vim.VirtualMachineFileLayout

LayoutEx             : VMware.Vim.VirtualMachineFileLayoutEx

Storage              : VMware.Vim.VirtualMachineStorageInfo

EnvironmentBrowser   : EnvironmentBrowser-envbrowser-653

ResourcePool         : ResourcePool-resgroup-11

ParentVApp           :

ResourceConfig       : VMware.Vim.ResourceConfigSpec

Runtime              : VMware.Vim.VirtualMachineRuntimeInfo

Guest                : VMware.Vim.GuestInfo

Summary              : VMware.Vim.VirtualMachineSummary

Datastore            : {Datastore-datastore-591}

Network              : {Network-network-145}

Snapshot             :

RootSnapshot         : {}

GuestHeartbeatStatus : green

LinkedView           :

Parent               : Folder-group-v41

CustomValue          : {}

OverallStatus        : green

ConfigStatus         : green

ConfigIssue          : {}

EffectiveRole        : {-1}

Permission           : {}

Name                 : test-vm1

DisabledMethod       : {Destroy_Task, UnregisterVM, RevertToCurrentSnapshot_Task, RemoveAllSnapshots_Task...}

RecentTask           : {}

DeclaredAlarmState   : {alarm-10.vm-653, alarm-11.vm-653, alarm-2.vm-653, alarm-23.vm-653...}

TriggeredAlarmState  : {}

AlarmActionsEnabled  : True

Tag                  : {}

Value                : {}

AvailableField       : {FA.GosAgent}

MoRef                : VirtualMachine-vm-653

Client               : VMware.Vim.VimClientImpl

Tags (2)
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Try $vm.ExtensionData.Guest.GuestFullName


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

14 Replies
LucD
Leadership
Leadership
Jump to solution

Try $vm.ExtensionData.Guest.GuestFullName


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

MKguy
Virtuoso
Virtuoso
Jump to solution

You can use this one-liner to get a list of VMs with their configured and running Guest OS:

Get-VM | Sort | Get-View -Property @("Name", "Config.GuestFullName", "Guest.GuestFullName") | Select -Property Name, @{N="Configured OS";E={$_.Config.GuestFullName}},  @{N="Running OS";E={$_.Guest.GuestFullName}} | Format-Table -AutoSize
-- http://alpacapowered.wordpress.com
mprobst
Contributor
Contributor
Jump to solution

Thank you, this is what I was looking for

0 Kudos
jessem
Enthusiast
Enthusiast
Jump to solution

How can I output this to a csv or file?

Get-VM | Sort | Get-View -Property @("Name", "Config.GuestFullName", "Guest.GuestFullName") | Select -Property Name, @{N="Configured OS";E={$_.Config.GuestFullName}},  @{N="Running OS";E={$_.Guest.GuestFullName}} | Format-Table -AutoSize


0 Kudos
jessem
Enthusiast
Enthusiast
Jump to solution

How can I get this exported to a csv or excel file?

Get-VM | Sort | Get-View -Property @("Name", "Config.GuestFullName", "Guest.GuestFullName") | Select -Property Name, @{N="Configured OS";E={$_.Config.GuestFullName}},  @{N="Running OS";E={$_.Guest.GuestFullName}} | Format-Table -AutoSize


0 Kudos
LucD
Leadership
Leadership
Jump to solution

Try like this

Get-VM | Sort-Object -Property Name |

Get-View -Property @("Name", "Config.GuestFullName", "Guest.GuestFullName") |

Select -Property Name,

    @{N="Configured OS";E={$_.Config.GuestFullName}}, 

    @{N="Running OS";E={$_.Guest.GuestFullName}} |

Export-Csv report.csv -NoTypeInformation -UseCulture


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

jessem
Enthusiast
Enthusiast
Jump to solution

Worked great!  Thanks LucD.  Is there any other way to get a few more things out of this report.

vmem

vcpu

datacenter

cluster

vcenter folder or vm folder as example: discovered virtual machines?

0 Kudos
LucD
Leadership
Leadership
Jump to solution

See my reply in the other thread.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
MAThompsPCSO
Contributor
Contributor
Jump to solution

That worked perfectly!

0 Kudos
unibn
Contributor
Contributor
Jump to solution

Hey LucD,

i have a question about your Script.

I only need the output from Config.GuestFullName and i want to include it in my existing Script:

Get-VM -Location test | Select Name,NumCPU,MemoryMB,@{n="HardDiskSizeGB"; e={(Get-HardDisk -VM $_ | Measure-Object -Sum CapacityGB).Sum}},@{n="Date"; e={((Get-Date).ToString('yyyy-MM-dd'))}},@{n="IOLimit"; e={(Get-HardDisk -VM $_).ExtensionData.StorageIOAllocation.Limit | Measure-Object -Sum | Select -ExpandProperty Sum}},@{N="OS";E={$_.Guest.OSFullName}} | Export-Csv -Path "C:\powercli\VM_Report\csv_reports\$csvfile"

With Guest.OSFullName it works fine. But if i replace Guest.OSFullName with Config.GuestFullName, the output is empty.

It would be very kind of you, if you show me, how to include this in my existing Script above.

Ps. How can i paste code with syntax syntax highlighting this forum. 🙂

0 Kudos
LucD
Leadership
Leadership
Jump to solution

The Config.GuestFullName is a property under the ExtensionData property.
It is not exposed in the .Net object of a VM, like Guest.OSFullName is.

It is a property in the vSphere VirtualMachine object.

Get-VM -Location test |

Select Name,NumCPU,MemoryMB,

   @{n="HardDiskSizeGB"; e={(Get-HardDisk -VM $_ | Measure-Object -Sum CapacityGB).Sum}},

   @{n="Date"; e={((Get-Date).ToString('yyyy-MM-dd'))}},

   @{n="IOLimit"; e={

   (Get-HardDisk -VM $_).ExtensionData.StorageIOAllocation.Limit | Measure-Object -Sum | Select -ExpandProperty Sum}},

   @{N="OS";E={$_.Guest.OSFullName}},

   @{N= 'AlternateGuestName';E={$_.ExtensionData.Config.GuestFullName}} |

Export-Csv -Path "C:\powercli\VM_Report\csv_reports\$csvfile"

The HTML code can just be copied from the editor window in Visual Studio Code.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
unibn
Contributor
Contributor
Jump to solution

Ah, stupid mistake... Thank you LucD. Regards Henning

0 Kudos
vasqu
Contributor
Contributor
Jump to solution

You have most likely figured this out by now you but ill post as it may benefit someone. I needed to get all my Windows servers to build a list to ingest into another script.

I did the following:

$VMs = get-vm

$VMs.extensiondata.guest | where {$_.GuestFullName -like "Microsoft*"} | select HostName,IpAddress,GuestFullName | export-csv c:\temp\WinVMs.csv -NoTypeInformation

 

You can also condense to one line and not user a variable:

(get-vm).extensiondata.guest | where {$_.GuestFullName -like "Microsoft*"} | select HostName,IpAddress,GuestFullName | export-csv c:\temp\WinVMs.csv  -NoTypeInformation

 

To get this info for all just drop the where statement:

(get-vm).extensiondata.guest | select HostName,IpAddress,GuestFullName | export-csv c:\temp\WinVMs.csv  -NoTypeInformation

--OR--

$VMs = get-vm

$VMs.extensiondata.guest | select HostName,IpAddress,GuestFullName | export-csv c:\temp\WinVMs.csv -NoTypeInformation

 

 

 

0 Kudos
Mdmohiuddinchy
Contributor
Contributor
Jump to solution

From where to run this commands or script.

0 Kudos