This website uses cookies to ensure you get the best experience on our website. Learn more

Preventing Sleep when patching a new image
(Last updated on August 2, 2018)
Patching a machine can be a tedious process, especially if the machine goes to sleep before the process is complete. This has been a common problem our Specops Deploy customers have run into when creating an image for Windows 7. In this post, I will demonstrate the steps to take to prevent sleep with PowerShell and the MDT workbench.
Use the following PowerShell script to set the power options to never turn off the disks, and screen, or go into stand-by or hibernation. I named the file script.ps1
powercfg.exe -change disk-timeout-ac 0 powercfg.exe -change disk-timeout-dc 0 powercfg.exe -change monitor-timeout-ac 0 powercfg.exe -change monitor-timeout-dc 0 powercfg.exe -change standby-timeout-ac 0 powercfg.exe -change standby-timeout-dc 0 powercfg.exe -change hibernate-timeout-ac 0 powercfg.exe -change hibernate-timeout-dc 0
Copy the script to the deployment repository folder under Scripts\Misc\Power-Options.
Open the MDT workbench, choose the Task sequences folder and right click on the original media Task Sequence, in this case Windows 7 and choose properties.
Under State Restore, right-click on Tattoo Task sequence and chose General, Run Powershell script.
Name: Power-Options
PowerShell script: %SCRIPTROOT%\Misc\Power-Options\script.ps1
In the Options tab, select continue on error and click OK.
Finally, I published from Specops Deploy / OS admin software tool in tab servers and test-deployed to a new virtual machine that would never go into sleep mode even if the deployment of the windows 7 machine takes 14 hours.
Remember to reset the settings through a Power-plan GPO preference when you add the machine to the domain again. Otherwise, the machine will never go into sleep and waste power for the company.
Happy image deployment!