Link to home
Start Free TrialLog in
Avatar of BSModlin
BSModlinFlag for United States of America

asked on

Create Powershell script to Start VM

I have a Server 2012 R2 Hyper-V box that is scheduled to restart every night.  When the server comes back up, all VMs automatically start except an RSA Authentication MGR Linux VM.  I have checked the Hyper-V settings and it is set to restart automatically like the others, but does not.  

To get it started, I must do a GPUPDATE /FORCE, and then start the VM and poof, it works.  

With that being said, I would like to run a powershell script that runs at COMPUTER startup that will run a GPUPFDATE /FORCE, pause for like 120 seconds, and then issue a start command to that particular VM.

Can somebody help?
ASKER CERTIFIED SOLUTION
Avatar of David Johnson, CD
David Johnson, CD
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of BSModlin

ASKER

Thanks.... And how do you recommend I initiate the script??
1. from an elevated powershell session (run as administrator)
set-executionpolicy remotesigned
accept the change in the policy as by default scripts are disabled.

create a scheduled task trigger on machine startup
task
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
argument
c:\path\yourscriptname.ps1
http://windows.microsoft.com/en-ca/windows/schedule-task#1TC=windows-7