Hi guys,
I am trying to create a simple report that contains
Virtual Centre Name - ESX Host - Guest Name - Power State - VM Tools installed
I don't think I can get the VC name but I can just inject that manually, but do need all the others.
Can you help
different technique:
Get-VMHost | select {$_.Name}, { (Get-VM -Location $_).Name }, { (Get-VM -Location $_).PowerState }
Hal Rottenberg
Co-Host, PowerScripting Podcast (http://powerscripting.net)
The following should put you on the way.
Get-VMHost | %{$esx = $_; Get-VM -Location $_} | ` %{$vm = Get-View $_.ID; Write-Output $esx.name $_.name $_.powerstate $vm.config.tools.toolsVersion}
For the tools it shows the installed version (0 means not installed).
This can be converted to a Boolean (true/false) with an IF statement.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Close..
I am using Get-VMHost | %{$esx = $_; Get-VM -Location $_} | %{Write-Output $esx.name $_.name $_.powerstate}
but the ouput I am getting is :
vm000020
CEOV00010
PoweredOn
When I need : vm000020, CEOV00010, PoweredOn
Can anyone else help
different technique:
Get-VMHost | select {$_.Name}, { (Get-VM -Location $_).Name }, { (Get-VM -Location $_).PowerState }
Hal Rottenberg
Co-Host, PowerScripting Podcast (http://powerscripting.net)
Thank you for your help - just what I needed.
And I can follow the login in this one
Read up on "calculated properties" in powershell with select-object and format-table. Powerful stuff. Note that you can make the column names pretty by putting a label in a hashtable.
$column1 = @{ Name = "column one"; Expression = { # code goes here } } # select-object uses Name key
$column1 = @{ Label = "column one"; Expression = { # code goes here } } # format-table uses Label key
(Don't ask me why they take two different keys for the same purpose. I call it a bug and logged it as such on the powershell connect website.)
Hal Rottenberg
Co-Host, PowerScripting Podcast (http://powerscripting.net)