socius
Contributor
Contributor

How do I get Virtual Machine Name Output from 'Get-VM | Get-AdvancedSetting' command?

Jump to solution

Hello, I have a question that is hopefully fairly simple to answer.

I am having this problem explained in KB 2078352, and want a list of affected VMs before hotfixing them, in order to see if it has helped with our problem or not.


Example line:

get-vm | Get-AdvancedSetting -Name tools.deployPkg.fileName

Name                 Value                Type                 Description

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

tools.deployPkg.f... imc1D01.tmp          VM

tools.deployPkg.f... imc937E.tmp          VM

tools.deployPkg.f... imc32EE.tmp          VM

tools.deployPkg.f... imc6030.tmp          VM

This only outputs the value of the file names, but not the VM names. So I am simply wondering how I can get an output of the virtual machine name together with this information?

Thanks in advance.

1 Solution

Accepted Solutions
LucD
Leadership
Leadership

Try adding a Format-Table perhaps

Get-VM | Get-AdvancedSetting |
Select @{N="VM";E={$_.Entity.Name}},Name,Value | Format-Table -AutoSize


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

View solution in original post

10 Replies
schepp
Leadership
Leadership

Hi,

the VMs name is available in the attribute Entity:

get-vm | Get-AdvancedSetting -Name tools.deployPkg.fileName | Select Entity,Name,Value


You can of course also show the other attributes you had above, like type and description


Tim

socius
Contributor
Contributor

That is certainly helpful. However, that command line only outputs Entity when I run it.

0 Kudos
schepp
Leadership
Leadership

When you add "| Select Entity,Name,Value" to your original command you only get the Entity as output and not the name and value?

0 Kudos
socius
Contributor
Contributor

Yes, it looks like this. (Real servernames obscured):

PowerCLI C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI> get-vm server* | Get-AdvancedSetting -Name tools.deployPkg.fileName | Select Entity,Name,Value

Entity

------

server1

server2

server3

server4

PowerCLI C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI>

I tried running it with Select * instead and then I get all the information, like below:

Uid     : /VIServer=domainuser@vcenterserver:443/VirtualMachine=VirtualMachine-vm-5004/AdvancedSetting=VMSetting-tools.deployPkg.fileName/
Value   : imc6030.tmp

Description :

Type    : VM
Entity  :server1
Id      : VMSetting-tools.deployPkg.fileName
Name    : tools.deployPkg.fileName
Client  : VMware.VimAutomation.ViCore.Impl.V1.VimClient
0 Kudos
schepp
Leadership
Leadership

Strange, it's working perfectly fine for me with Powershell Version 3.0 and PowerCLI 5.5 Release 2

What version are you using?

$PSVersionTable

Get-VIToolkitVersion

0 Kudos
socius
Contributor
Contributor

PowerCLI C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI> $PSVersionTable

Name                           Value

----                           -----

PSVersion                      4.0

WSManStackVersion              3.0

SerializationVersion           1.1.0.1

CLRVersion                     4.0.30319.18444

BuildVersion                   6.3.9600.16406

PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0}

PSRemotingProtocolVersion      2.2

PowerCLI C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI> Get-VIToolkitVersion

PowerCLI Version

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

   VMware vSphere PowerCLI 5.5 Release 2 build 1671586

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

Snapin Versions

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

   VMWare AutoDeploy PowerCLI Component 5.5 build 1598391

   VMWare ImageBuilder PowerCLI Component 5.5 build 1598391

   VMware License PowerCLI Component 5.5 build 1265954

   VMware VDS PowerCLI Component 5.5 build 1671576

   VMware vSphere PowerCLI Component 5.5 build 1671576

0 Kudos
LucD
Leadership
Leadership

Go for a calculated property. Like this

Get-VM | Get-AdvancedSetting |
Select @{N="VM";E={$_.Entity.Name}},Name,Value


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

0 Kudos
socius
Contributor
Contributor

Hello and thankyou for responding. That command gives me the same output as the above one, with only the Entity, except it names the column VM instead.

0 Kudos
LucD
Leadership
Leadership

Try adding a Format-Table perhaps

Get-VM | Get-AdvancedSetting |
Select @{N="VM";E={$_.Entity.Name}},Name,Value | Format-Table -AutoSize


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

View solution in original post

socius
Contributor
Contributor

PowerCLI C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI> Get-VM server* | Get-AdvancedSetting -Name tools.deployPkg.fileName | Select @{N="VM";E={$_.Entity.Name}},Name,Value | Format-Table -AutoSize

VM          Name                     Value

--          ----                     -----

server1    tools.deployPkg.fileName imc1D01.tmp

server2    tools.deployPkg.fileName imc937E.tmp

server3    tools.deployPkg.fileName imc32EE.tmp

server4    tools.deployPkg.fileName imc6030.tmp

There we go! Big thanks to both of you for helping out.

Edit:

In case someone else wants to do the same thing as me, I also added something to filter out only the VMs that have the offending files remaining.

Get-VM | Get-AdvancedSetting -Name tools.deployPkg.fileName | Where-Object {$_.Value -ne ''} | Select @{N="VM";E={$_.Entity.Name}},Name,Value | Format-Table -AutoSize

0 Kudos