Archive

Archive for August, 2011

Deploying A Customized Power Plan in Windows 7 with MDT

August 1, 2011 10 comments

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   

Wend

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: ,
%d bloggers like this: