I`d like to pull all GuestOS names from different VMs in vCenter and want to have them listed one underneath the other. The output should be trimmed so only the Guest OS name is shown (no "$.Extension...") -ExpandProperty is not sufficient here.
$Oss=Get-VM | select {$_.ExtensionData.Guest.GuestFullName} -Unique
$Oss
Output using PS1 file or in Powershell ISE:
$_.ExtensionData.Guest.GuestFullName : Microsoft Windows Server 2012 (64-bit)
$_.ExtensionData.Guest.GuestFullName : CentOS 4/5/6/7 (64-bit)
$_.ExtensionData.Guest.GuestFullName : Linux 3.10.0-862.14.4.el7.x86_64 CentOS Linux release 7.5.1804 (Core)
$_.ExtensionData.Guest.GuestFullName : SUSE Linux Enterprise 11 (64-bit)
Output "normal" Powershell console:
$_.ExtensionData.Guest.GuestFullName
Microsoft Windows Server 2008 R2 (64-bit)
Microsoft Windows Server 2012 (64-bit)
CentOS 4/5/6/7 (64-bit)
CentOS 4/5/6 (32-bit)
I`d like to have the same output like the latter one (or even without Extensiondata..). Any idea?
And why is it different anyway?
thanks!
I believe you are trying to retrieve a property value of objects sub-property, see example 9 in this link for more details:
Get-VM | Select @{N="GuestFullName";E={$_.ExtensionData.Guest.GuestFullName}}