Solved

How do I configure a Timed restart for Multiple Hyper-V VMs on Server 2012?

Posted on 2014-11-17
10
660 Views
Last Modified: 2014-11-19
How do I script a timed restarting of multiple VMs on Hyper-v 2012 Server. I have tested the restart process and found it needs to run in PowerShell running as administrator. I have tried to run a simple shutdown -r -f, and having task scheduler keep time. Help please.
0
Comment
Question by:technologyone
  • 6
  • 4
10 Comments
 
LVL 53

Expert Comment

by:McKnife
ID: 40448378
The restart can be done from inside the machines (task scheduler on each machine or task scheduler on one machine that does shutdown remote machines ->look at the options of shutdown.exe /?), or it can be done through the host - yes, powershell.

please articulate what problems you are seeing, it's very simple.
0
 

Author Comment

by:technologyone
ID: 40449624
I would like to run this from the host if possible. I have about 50 VMs and want easy modification for the future. I am having trouble scripting the Restart-VM in PowerShell to run as administrator. I know I am not doing something, but I am relatively new to scripting.
0
 
LVL 53

Expert Comment

by:McKnife
ID: 40449655
What trouble do you have?
The restart-vm has examples in its help, did you read those?
The vmhost could start a simple restart.ps1 script though task scheduler using system rights (the system account would be the executioner).
0
 

Author Comment

by:technologyone
ID: 40449983
In what I was reading it did not look like I could use a restart "all" type command.
0
 
LVL 53

Accepted Solution

by:
McKnife earned 500 total points
ID: 40450096
You can. Use the command
get-vm |restart-vm -confirm
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 

Author Comment

by:technologyone
ID: 40450206
I have the script running like this...

restart-vm machine1 -force

This only works as long as it is directly in the task scheduler arguments section. If I put this script in a restart.ps1 file and insert this in the filed it errors out and I cant read the error before it is gone.
0
 

Author Comment

by:technologyone
ID: 40450228
Ok I have inserted the  " get-vm |restart-vm -force " on the Task Scheduler arguments line and it seems to be working. I will try it in production tonight. Thanks for the suggestion.
0
 
LVL 53

Expert Comment

by:McKnife
ID: 40450249
Turn on this policy: computer config - policies - adm. templates - Windows Components/Windows PowerShell - Execution Policy: Allow local scripts and remote signed scripts
0
 

Author Comment

by:technologyone
ID: 40450260
I will post tomorrow to close question after in production solution has run. Thank you again for the assistance.
0
 

Author Closing Comment

by:technologyone
ID: 40452247
I am closing this job. thanks
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

This is a little timesaver I have been using for setting up Microsoft Small Business Server (SBS) in the simplest possible way. It may not be appropriate for every customer. However, when you get a situation where the person who owns the server is i…
Ever notice how you can't use a new drive in Windows without having Windows assigning a Disk Signature?  Ever have a signature collision problem (especially with Virtual Machines?)  This article is intended to help you understand what's going on and…
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now