Hi,
Please help to get the list of all windows VMs that powered on
I am stuck with this how can i add another parameter
get-vm | Where {$_.Guest -match 'windows'}
Please help
Or use the more accurate and faster
(Get-VM).where{$_.PowerState -eq 'PoweredOn' -and $_.Guest.OSFullName -match 'Windows'}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
You can use the below command -
Get-VM | ? {($_.GuestId -match "Windows") -and ($_.powerstate -eq "PoweredOn")}
Please consider marking this answer as "correct" or "helpful" if you think your questions have been answered.
Cheers,
Supreet
Or use the more accurate and faster
(Get-VM).where{$_.PowerState -eq 'PoweredOn' -and $_.Guest.OSFullName -match 'Windows'}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
LucD - Can you please explain how your command would be more accurate and faster than the one I shared? Since I have just started to learn PowerShell (and PowerCLI), your inputs will definitely help me understand more
Cheers,
Supreet
Sure.
The where method, as I also showed in my recent VMworld session, is faster than the Where-Object cmdlet.
The test on the Guest property is comparing the string representation of the complete Guest object, while the actual OS name is in the nested property $_.Guest.OSFullName.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Oh nice! When we run <Get-VM -Name VM_Name | Format-List *>, we do not see the property 'Guest.OSFullName'. How do we obtain a list of available nested properties?
Cheers,
Supreet
Use the Format-Custom cmdlet with the Depth parameter.
For example (but be aware that this produces a lot of output)
Format-Custom -Depth 2
PS: and please stop begging for points in your replies. That is not considered good practice.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Custom indeed produces a lot of output Thanks, again!
Regarding the points, I don't mention it for all the replies. Anyways, will have none going forward
Cheers,
Supreet
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
How to get the powered on vm's list with vmtools and tools version.
Try something like this
Select Name,PowerState,@{N='ToolsVersion';E={$_.Guest.ToolsVersion}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thank you, i am able to pull the list.
i have used the below one.
Get-VM | where{$_.PowerState -eq 'PoweredOn'} | Select Name,PowerState,@{N=”HardwareVersion”; E={$_.Extensiondata.Config.Version}}, @{N=”ToolsVersion”; E={$_.Extensiondata.Config.Tools.ToolsVersion}},@{N=”ToolsStatus”; E={$_.Extensiondata.Summary.Guest.ToolsStatus}},@{N=”ToolsVersionStatus”; E={$_.Extensiondata.Summary.Guest.ToolsVersionStatus}}, @{N=”ToolsRunningStatus”; E={$_.Extensiondata.Summary.Guest.ToolsRunningStatus}}