Hi Luc,
i can now confirm that it works like you have written. Although it was nice try to get only those which are running, it will still output a vm which is running and the Family can be blank. I receive a list now all running vms and one of them had the Family column blank.
Now two interesting things:
1)
If you do filter like this :
$filter=@{"Guest.GuestFamily"="windowsGuest"}
Then i saw that by default it is not returning templates, all received vms have Template column set to 'False' (is this 100% default behaviour of get-view for virtual machine , that it will ommit the templates?)
2)
Why do i have to have vm running in order to check if this is a windows guest ? while having filter
$filter=@{"Guest.GuestFamily"="windowsGuest"}
applied, i see in the output vms with:
Name Guest State Family Template
vm1 notRunning windowsGuest False
So for some reason it recognizes the familyOS for vms that are powered off.
Why do i have to have vmware tools instaled within guest os in order to get the vm family os ?
->
I have noticed that after creating a blank vm and selecting an os for it :
"Microsoft Windows 8 (32-bit)"
This is not populating the guest object
"
ToolsStatus : toolsNotInstalled
ToolsVersionStatus : guestToolsNotInstalled
ToolsVersionStatus2 : guestToolsNotInstalled
ToolsRunningStatus : guestToolsNotRunning
ToolsVersion :
GuestId :
GuestFamily :
GuestFullName :
"
But still i am able to check what OS is there by getting the
config.GuestFullName
this is still populated even if tools are not installed. And i think those fields are not populated the the vm is poweredOfff. So it is wrong to rely on the filed Guest.GuestFamily if we still want to receive vms that are poweredoff.
So this
$filter=@{"Config.GuestFullName"="windows";"Config.Template"=[string]$false}
Get-View -ViewType "VirtualMachine" -Filter $filter |
Sort-Object Name |
Select Name,
@{N="Family";E={$_.Guest.GuestFamily}},
@{N="Template";E={$_.Config.Template}},
@{N="OSname";E={$_.Config.GuestFullName}}
Returns what i wanted, all vms which have windows in the name of the OS(this option need to be specified while creating vm though)
Again i think i finally understood now how this works. Thank Luc !
@update :/
having filter like this
$filter=@{"Guest.GuestFamily"="windowsGuest"} from what you have said , should show me Empty ones and with windowsGuest, because empty should be counted as true. But in fact i am receiving list with all Family: windowsGuest, no empty one. So it acts like it searchs vms only with vmware tools installed. Can you comment on this ?
Message was edited by: Grzesiekk