Hello All,
If i use a property on get-vm I get the results such as get-vm.harddisks
Storagetype:
name:
filename:
etc.
Now i am trying to take the stroagetype and check if its Type = thin then list.
so what I am doing is creating a custom psobject and adding the $_.storagetype in there.
Now how do i do if($object.storagetype -eq "Thin"){ xxx}
Please advice
Thanks
RJ
This can be done in a similar way as the other thread you started, with a Where-clause.
foreach($vm in Get-VM){ foreach($hd in ($vm.Harddisks | where {$_.StorageFormat -eq "Thin"})){ New-Object PSObject -Property @{ VM = $vm.Name HD = $hd.Name Type = $hd.StorageType } } }
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks Luc,
So here we are creating three members in the new object - which is $New-Object? or what is the object name?
RJ
The cmdlet is New-Object and we use a builtin, empty object, which is called PSObject.
The New-Object cmdlet places the new object on the pipeline.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference