I'm trying to combine a few one liners into a single powercli script using PowerCLI 4.0 U1
I am getting a list of all powered on VMs in a cluster (particular cluster I'm working on has all of its VMs on this single array) using this command:
get-vm -Location DS | where {$_.powerstate -match "on"}
I am getting a list of all datastores on this array based on our datastore naming convention. I'm sure there is a better way to do this but for now it works using this command:
get-datastore | where {$_.name -like "dsname*"}
I am also shutting down a list of VMs using this command:
get-content c:\vm_list.csv | % { Get-VM $_ | Shutdown-VMGuest -confirm:$false }
What I'd like to do is put these together into one script. I'm sure it's something simple but I'm not sure how to do it.
So to summarize my goal is to have a script that will shutdown all VMs that are currently powered on on a particular array and then power these VMs back on.
Thanks