?
Solved

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

Posted on 2014-11-17
10
Medium Priority
?
1,508 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
10 Comments
 
LVL 56

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 56

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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 56

Accepted Solution

by:
McKnife earned 2000 total points
ID: 40450096
You can. Use the command
get-vm |restart-vm -confirm
0
 

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 56

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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Using the Hyper-V Manager requires administrator rights. This guide shows how to add shortcuts and Start Screen tiles for normal users to quickly connect to local virtual machines rather than using the recommended Remote Desktop connection.
In this article, I am going to show you how to simulate a multi-site Lab environment on a single Hyper-V host. I use this method successfully in my own lab to simulate three fully routed global AD Sites on a Windows 10 Hyper-V host.
This video Micro Tutorial explains how to clone a hard drive using a commercial software product for Windows systems called Casper from Future Systems Solutions (FSS). Cloning makes an exact, complete copy of one hard disk drive (HDD) onto another d…
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…
Suggested Courses

741 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