We are having to stop & start a random list of Virtual Machines this weekend. They are not part of any distinct container, so my idea was to read a list of virtual machines and perform a get-vm | stop<start>-vm. I am having problems with my limited scripting ability. Here was my string:
get-content <text-file-name> | get-vm | stop-vm
That did not work. I also tried a get-content with a foreach command, but I believe my syntax was bad. Could someone provide some assistance? Thank you.
We are having to stop & start a random list of Virtual Machines this weekend. They are not part of any distinct container, so my idea was to read a list of virtual machines and perform a get-vm | stop<start>-vm. I am having problems with my limited scripting ability. Here was my string:
get-content <text-file-name> | get-vm | stop-vm
That did not work. I also tried a get-content with a foreach command, but I believe my syntax was bad. Could someone provide some assistance? Thank you.
You were pretty close, try:
get-content <text-file-name> | foreach { get-vm $_ | stop-vm }
This assumes that each VM name is on a line by itself.
Thank you that was it...