I have a script that I run after I update our Linked Clones . The script runs through VM's for a Resource Pool and creates three scheduled tasks that shutdown, then power off then power on VM's.
Part of my code I have is this:
Get-View -ViewType VirtualMachine -Filter @{"ResourcePool" = "MYRESOURCEPOOL"}
And from I create the scheduled tasks in a For statement.
Instead of creating different scripts or rerunning the thing for other Resource Pools I would prefer to filter the view but refer to multiple Resource Pools.
So something like:
Get-View -ViewType VirtualMachine -Filter @{"ResourcePool" = "MYRESOURCEPOOL1", "MYRESOURCEPOOL2"}
But I can't seem to get the right syntax to filter on multiple resource pools.
Can anyone assist?
The right hand is a RegEx expression, so you can use the RegEx 'or', like this
Get-View -ViewType VirtualMachine -Filter @{"ResourcePool" = "MYRESOURCEPOOL1|MYRESOURCEPOOL2"}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
The right hand is a RegEx expression, so you can use the RegEx 'or', like this
Get-View -ViewType VirtualMachine -Filter @{"ResourcePool" = "MYRESOURCEPOOL1|MYRESOURCEPOOL2"}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Worked a treat, many thanks.