Question-er XDD
Question-er XDD

Reputation: 767

How to find all VM/Hyper-V and then reboot them on Window Server 2012 with the use of Power-shell

I would like to ask how to find all VM/Hyper-V on Window Server 2012 with the use of power-shell and then restart/reboot them with the use of power-shell script?

The next thing is: I cannot even find any get command for it: enter image description here

================== Added in 2014-08-15 have find a reference link that help me a lot, just share here http://technet.microsoft.com/en-us/library/hh848479.aspx

Upvotes: 0

Views: 1282

Answers (1)

Martin Zugec
Martin Zugec

Reputation: 165

Run Powershell elevated (!) and execute following:

ForEach ($VM in Hyper-V\Get-VM | Where {$_.State -ne "Off") {
        Restart-Computer -ComputerName $VM.Name
}

Non-elevated Powershell will not return any results.

Martin

Upvotes: 1

Related Questions