Home > Deployment, MDT > Deploying A Customized Power Plan in Windows 7 with MDT

Deploying A Customized Power Plan in Windows 7 with MDT

During our Windows 7 deployment we needed to deploy a customized power plan to our clients.  Windows provides an easy way to import and export power plans using the powercfg.exe utility.  With a little VB scripting automating the import of the plan through MDT is easy.

Here is the script I was using to import our customized plan and set it to active.

strPowerPlanFile = "c:\Folder\PowerPlan.pow"

Set objShell = CreateObject("WScript.Shell")

Set objWshScriptExec = objShell.exec("powercfg.exe -import " & strPowerPlanFile)

Set objStdOut = objWshScriptExec.stdOut


While Not objStdOut.AtEndOfStream

   strLine = objStdOut.ReadLine

   If InStr(strLine,"GUID:") Then

    strGuid = Right(strLine,36)     

   End If   


objShell.run "powercfg -setactive " & strGuid

Not much to it really.  First we run the powercfg.exe utility with the –import command line to import the file that contains the customized plan.  Each time you import a plan it gets a new GUID every time.  Powercfg outputs the GUID when the import completes.  We capture this line from the output, parse it, and then run the powercfg.exe utility again with the –setactive option to activate our new plan.

Now all you need to do is add a new step to your MDT TS to execute this script in the State Restore phase. 

Categories: Deployment, MDT Tags: ,
  1. Markus
    April 2, 2012 at 6:35 pm

    thanks. worked for me (using with novell zcm 11 bundle)

  2. Alan
    August 7, 2012 at 10:02 am


    I am attempting to use this script in MDT 2012. I believe I must be close to following your steps. Basically….

    1. Exported out a Win7 laptop PowerPlan.pow
    2. Saved as .vbs and modified the script above to reflect my .pow path in the strPowerPlanFile
    3. Added a step in my TS in the state restore with the command line cscript.exe “%SCRIPTROOT%\PowerLaptop.vbs” right after Post-Apply Cleanup.
    4. Manually ran the PowerLaptop.vbs to test it and it worked.

    I have tried running it twice now in MDT and the laptop I am trying to image still goes to sleep and has the default Windows power settings when the imaging process appears to be complete. Problem is not everything is complete. There are still files left on my D: partition (Minint folder) and in MDT it show that the process stalls at around 69% step 60 of 86. I would appreciate any help or ideas you might have on this topic.


    • Alan
      August 7, 2012 at 6:58 pm

      It appears that after some more research sleep is not causing my problem. I think the HP SSM was rebooting MDT after finishing its driver installation. After the reboot my MDT would not always finish the imaging job. I added /NOREBOOT to my command line and so far that seems to be stopping the reboot.

      I would still like to figure out why I have had no luck with the power management script.

  3. August 7, 2012 at 9:41 pm


    Is your pow file located in the image or are you calling it from the MDT share? I have mine located in a subfolder in the image. Do you have the step in MDT to continue on error? If not can you try turning that on to see if the script is erroring out.


    • Alan
      August 10, 2012 at 9:56 am

      Doing it that way you outlined above worked. Added the POW files to the image verses calling them from the server. Thanks! Do you have any advice on how to use a MDT variable to pass laptop POW or desktop POW in the same TS?

    • aj
      December 9, 2016 at 3:09 pm

      Mike my pow file is MDT share, So How Can I give the path?

  4. August 10, 2012 at 12:56 pm

    A quick and dirty way of doing it is to use the IsLaptop and IsDesktop TS variables to run the corresponding step. You would create 2 steps (one for laptop and one for desktops). In each one you would configure a script for importing either the desktop or laptop POW. Then in the step click on the Options tab, click Add > Task Sequence Variable. Enter in either IsLaptop or IsDesktop, set condition to equal, and set value to TRUE. Now each step will only run if the TS variable is set to IsLaptop or IsDesktop.

    A more elgant way of doing this would be to read those variables from MDT in the script and then depending on what is set execute the correspoing import command. If there was interest I could probably expand on this and do a whole blog post on it.

  5. Jorge
    May 10, 2013 at 2:18 pm

    Work like a charm. Thank you Master.

  6. Sanju
    March 4, 2014 at 6:44 am

    How can i get rid of the file location when i create media (ISO or Pendrive boot)
    strPowerPlanFile = “c:\Folder\PowerPlan.pow”

    as the location wont exist at the time of installation

  7. aj
    December 9, 2016 at 2:56 pm

    I saved the pow file in script folder and gave the path in the first line and added it TS. It didn’t work. Am I missing anything?

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: