Hi,
I am trying to get the VMs and its Datastore Info but I would like to exclude from particular VMs, which is not working using below. The exclude Datastore option is not working.
Please help!!
Get-Folder "Finance" | Get-VM | where {$_.Datastore.Name -ne "MyDS*"} | Select Name, Datastore
The meta character * only works with the -like or -notlike operator, not the -ne operator.
Also, the VirtualMachine object does not have a property Datastore.
You could do
Get-Folder "Finance" |
Get-VM -PipelineVariable vm |
Get-Datastore | where{$_.Name -notlike "MyDS*"} |
select @{N='VM';E={$vm.Name}},@{N='Datastore';E={$_.Name}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
The meta character * only works with the -like or -notlike operator, not the -ne operator.
Also, the VirtualMachine object does not have a property Datastore.
You could do
Get-Folder "Finance" |
Get-VM -PipelineVariable vm |
Get-Datastore | where{$_.Name -notlike "MyDS*"} |
select @{N='VM';E={$vm.Name}},@{N='Datastore';E={$_.Name}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thank you very much LucD. that worked perfectly 🙂