VMware Cloud Community
winsolo
Enthusiast
Enthusiast
Jump to solution

Properties similar to "Get-AdvanceSetting" of a VM in Get-View

Are there properties available in Get-View that are similar to Get-AdvancedSetting | Where {$_.Name -like "*tools*"}

The below cmdlet is able to give me these specific info related to vmtools of a VM

get-vm TestVM | Get-AdvancedSetting | Where {$_.Name -like "*tools*"} | FT -AutoSize


Name                                 Value                             Type Description

----                                 -----                             ---- -----------

tools.guest.desktop.autolock         FALSE                             VM

tools.remindInstall                  FALSE                             VM

toolsInstallManager.lastInstallError 21009                             VM

toolsInstallManager.updateCounter    11                                VM

vmware.tools.internalversion         10305                             VM

vmware.tools.requiredversion         10346                             VM

guestinfo.toolsInstallErrCode        1601                              VM

guestinfo.vmtools.buildNumber        8267844                           VM

guestinfo.vmtools.description        VMware Tools 10.2.1 build 8267844 VM

guestinfo.vmtools.versionNumber      10305                             VM

guestinfo.vmtools.versionString      10.2.1                            VM

I'm looking to integrate the above info into the below script

Get-VM "TestVM1", "TestVM2" -ErrorAction SilentlyContinue | % { Get-View $_.id } | Select-Object name,

@{Name="Running OS";E={$_.Guest.GuestFullName}},

@{Name="ToolsUpgradePolicy"; Expression={$_.Config.Tools.ToolsUpgradePolicy}}

@{Name="LastInstallError";E={(Get-AdvancedSetting -Entity $_.Name | Where-Object {$_.Name -eq "toolsInstallManager.lastInstallError"}).Value}},

@{Name="InstallErrCode";E={(Get-AdvancedSetting -Entity $_.Name | Where-Object {$_.Name -eq "guestinfo.toolsInstallErrCode"}).Value}},

@{Name="Description";E={(Get-AdvancedSetting -Entity $_.Name | Where-Object {$_.Name -eq "guestinfo.vmtools.description"}).Value}},

@{Name="LastInstallError";E={(Get-AdvancedSetting -Entity $_.Name | Where-Object {$_.Name -eq "toolsInstallManager.updateCounter"}).Value}} | Out-gridview

This only works for the 1st VM and it fails for the 2nd VM, therefore I'm unable to use the Get-AdvancedSetting cmdlet

Select-Object : The property cannot be processed because the property "LastInstallError" already exists.

At line:1 char:97

+ ... rAction SilentlyContinue | % { Get-View $_.id } | Select-Object name,

+                                                       ~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : InvalidOperation: (VMware.Vim.VirtualMachine:PSObject) [Select-Object], PSArgumentException

    + FullyQualifiedErrorId : AlreadyExistingUserSpecifiedPropertyNoExpand,Microsoft.PowerShell.Commands.SelectObjectCommand

1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

You can use the Get-View cmdlet immediately with the ViewType parameter.

With the Filter hash table, you can select the VMs based on their DisplayName.

Note that the Value in this hash table is a RegEx

PS: your error is caused by the fact that you use the same name LastInstallError twice

Get-View -ViewType VirtualMachine -Property Name,Guest,'Config.Tools.ToolsUpgradePolicy','Config.ExtraConfig' -Filter @{Name='TestVM1|TestVM2'} |

Select Name,

    @{Name="Running OS";E={$_.Guest.GuestFullName}},

    @{Name="ToolsUpgradePolicy"; Expression={$_.Config.Tools.ToolsUpgradePolicy}},

    @{Name="LastInstallError";E={($_.Config.ExtraConfig | Where-Object {$_.Key -eq "toolsInstallManager.lastInstallError"}).Value}},

    @{Name="InstallErrCode";E={($_.Config.ExtraConfig | Where-Object {$_.Key -eq "guestinfo.toolsInstallErrCode"}).Value}},

    @{Name="Description";E={($_.Config.ExtraConfig | Where-Object {$_.Key -eq "guestinfo.vmtools.description"}).Value}},

    @{Name="UpdateCounter";E={($_.Config.ExtraConfig | Where-Object {$_.Key -eq "toolsInstallManager.updateCounter"}).Value}} |

Out-gridview

  


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

View solution in original post

2 Replies
LucD
Leadership
Leadership
Jump to solution

You can use the Get-View cmdlet immediately with the ViewType parameter.

With the Filter hash table, you can select the VMs based on their DisplayName.

Note that the Value in this hash table is a RegEx

PS: your error is caused by the fact that you use the same name LastInstallError twice

Get-View -ViewType VirtualMachine -Property Name,Guest,'Config.Tools.ToolsUpgradePolicy','Config.ExtraConfig' -Filter @{Name='TestVM1|TestVM2'} |

Select Name,

    @{Name="Running OS";E={$_.Guest.GuestFullName}},

    @{Name="ToolsUpgradePolicy"; Expression={$_.Config.Tools.ToolsUpgradePolicy}},

    @{Name="LastInstallError";E={($_.Config.ExtraConfig | Where-Object {$_.Key -eq "toolsInstallManager.lastInstallError"}).Value}},

    @{Name="InstallErrCode";E={($_.Config.ExtraConfig | Where-Object {$_.Key -eq "guestinfo.toolsInstallErrCode"}).Value}},

    @{Name="Description";E={($_.Config.ExtraConfig | Where-Object {$_.Key -eq "guestinfo.vmtools.description"}).Value}},

    @{Name="UpdateCounter";E={($_.Config.ExtraConfig | Where-Object {$_.Key -eq "toolsInstallManager.updateCounter"}).Value}} |

Out-gridview

  


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

winsolo
Enthusiast
Enthusiast
Jump to solution

Brilliant. Thanks LucD

0 Kudos