Hi,
I can display the version of the tools with this
get-vm VMName | % { get-view $_.ID } | select Name, @{ Name="ToolsVersion"; Expression={$_.config.tools.toolsVersion}}
and i can insert text into the description field with this
get-vm name vmname | set-vm -description "blah blah"
But i'm struggling to understand how to get the toolsversion into the description ! I know it can't be hard, but i'm a scripting novice.
Thanks !
You could do that like this
$vm = Get-VM <VM-name> $version = ($vm | Get-View).config.tools.toolsVersion Set-VM -VM $vm -Description $version -Confirm:$false
or as a one-liner
Get-VM <VM-name> | Set-VM -Description ($_ | Get-View).config.tools.toolsVersion -Confirm:$false
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
You could do that like this
$vm = Get-VM <VM-name> $version = ($vm | Get-View).config.tools.toolsVersion Set-VM -VM $vm -Description $version -Confirm:$false
or as a one-liner
Get-VM <VM-name> | Set-VM -Description ($_ | Get-View).config.tools.toolsVersion -Confirm:$false
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thats great thanks !
Now, to figure out how to append that to the existing descriptions
You can just concatenate the 2 strings together like this
$vm = Get-VM <VM-name> $description = $vm.Description $version = ($vm | Get-View).config.tools.toolsVersion Set-VM -VM $vm -Description ($description + " " + $version) -Confirm:$false
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Just what i wanted, thanks again !
Great post.
I was wondering if there is a way to set this value into a custom field so I can sort VM's on version types.
Yes, adding the tools version to a custom field is possible.
See for details.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
*
Thanks for the prompt reply.
I am a bit new to powershell so please excuse the daft questions. I am trying to run the following as per the link you set
Get-VM "VIEW-TEST-1" | Set-CustomField -name "Version" ($_ | Get-View).config.tools.toolsVersion -Confirm:$false
but I am getting the following;
The argument cannot be null or empty.
At :line:3 char:70
+ Get-VM "VIEW-TEST-1" | Set-CustomField -name "Version" ($_ | Get-View) <<<< .config.tools.toolsVersion -Confirm:$false
Cannot validate argument because it is null.
Thanks in advance
*
You can do it this way
Get-VM "VIEW-TEST-1" | %{Set-CustomField -Entity $_ -name "Version" -value ( $_ | Get-View ).config.tools.toolsVersion -Confirm:$false}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I think that putting the tools version in an extra field is a good way of doing it. Sometimes it can look messy when there is already a description in the notes field. This method makes it nice and neat.
And you can use these custom attributes in the Virtual Machines tab in the VIC.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
That works perfectly, thanks for such a quick response.