Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the twentyseventeen domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /var/www/html/wp-includes/functions.php on line 6121
June 2018 – SCCMOG – Deployment Blog

OSD Task Seqeunce High Performance – Native PowerCFG – VBS – MDT -SCCM

So like a lot of ConfigMgr Admins out there I strive to produce the fastest and most robust task sequences I can. This obviously led me down the path of configuring the Power Settings on the OS during deployment and capture phases.

The issue that I found is probably like many of you have and that is that it requires exporting the native “PowerCFG.exe” from each version of the OS that you would like to dynamically change the power configuration during Operating System Deployment.

So Jack and I were discussing why… in short… do we not use the “PowerCFG.exe” that is is already in the OS that we are configuring. Anyway after a little persuasion we came up with this little beauty of a script. This script will also create a CMTrace “Log”  using its name in the Log folder that is currently in use in the Task sequence.

Setup is simple:

MDT Setup
  • For MDT just place it into the Scripts folder of you “Deployment Share”.”
    "<YourDeploymentShareDrive>:\<DeploymentShareRoot>\Scripts\Set-PowerCFG.wsf"
  • You can then call this during any stage of you Reference image capture i.e. WinPE or full OS phase to set the power cfg with these below Command Lines:
    "%ScriptRoot%\Set-PowerCFG.wsf" /High
    "%ScriptRoot%\Set-PowerCFG.wsf" /Bal
SCCM Setup
  • For SCCM you must be using the MDT integration (if you’re not… Start now!), you can make it work without it but I will not cover that here.
  • Find your current MDT Toolkit Package that is associated with the Task Sequence you would like to configure power settings in.
  • Open the “Source” location of your toolkit package, then open the scripts folder.

  • Once inside the scripts folder copy the “Set-PowerCFG.wsf” into it.

    • Now, update the Package in ConfigMgr.
    • Next we need to add the step to the task sequence. It must go after the “Use Toolkit Package” step in the task sequence. (If you have a reboot and remember to add another use “Toolkit package”.)
    • Create a new “Run Command Line Step” and add one of the below commands.
cscript.exe "%deployroot%\scripts\Set-PowerCFG.wsf" /High
cscript.exe "%deployroot%\scripts\Set-PowerCFG.wsf" /Bal

And that is it. Your Task sequence will now set the Power Configuration Profile using the current OS’s native “Powercfg.exe”

Anyway as always, script is provided as is and if you do mod it, there is a line to add your name.

The Script:

<job id="Set-PowerCFG">
<script language="VBScript" src="ZTIUtility.vbs"/>
<script language="VBScript">
 
' //***************************************************************************
' // ***** Script Header *****
' //
' // Solution: Solution Accelerator for Microsoft Deployment
' // File: Set-PowerCFG.wsf
' // Requirements: ZTIUtility.vbs Must be located in the same folder id running from ConfigMGR.
' // Author: SCCMOG Richie Schuster - SCCMOG.com
' // Moddedby: YOURNAMEHERE
' // Date: 21/03/2018
' // Purpose:  Script sets power profile during OS deployment - Can be run in WinPE or full OS.
' //
' // Usage: cscript Set-PowerConfig.wsf [/High] - Sets high performance | [/Bal] - Sets balanced performance. [/debug:true] 
' //
' // Customer Build Version: 1.0.0
' // Customer Script Version: 1.0.0
' // Customer History:
' //
' // ***** End Header *****
' //***************************************************************************
 
'//----------------------------------------------------------------------------
'//
'// Global constant and variable declarations
'//
'//----------------------------------------------------------------------------
 
'Option Explicit
Dim strPwrBalanced	: strPwrBalanced	= "381b4222-f694-41f0-9685-ff5bb260df2e"
Dim strPwrHighPerf	: strPwrHighPerf	= "8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c"
Dim strPwrCFGexe	: strPwrCFGexe		= "powercfg.exe"
Dim strPwrCFGswitch : strPwrCFGswitch	= " /S "
Dim strPwrCFGFolder : strPwrCFGFolder	= "PowerCFG"
Dim strWmessage		: strWmessage		= "Please enter one or more arguments 'E.G : /High for High Performance Profile' or '/Bal for Balanced Profile'"
Dim strWindir		: strWindir			= oShell.ExpandEnvironmentStrings("%Windir%")
Dim strSysWow64		: strSysWow64		= "SysWOW64"
Dim strSystem32		: strSystem32		= "System32"

Dim  PowerCFG, strPwrProfile, strPwrProfileLog, ostrCMD, iRetVal
 
'//----------------------------------------------------------------------------
'// End declarations
'//----------------------------------------------------------------------------

'//----------------------------------------------------------------------------
'// Main routine
'//----------------------------------------------------------------------------
'Begin
oLogging.CreateEntry "Beginning Set-PowerCFG 1.0.0", LogTypeInfo
oLogging.CreateEntry "Active Log Path: " & oUtility.LogPath, LogTypeInfo

'Take Script Args
oLogging.CreateEntry "Getting set Arguments...", LogTypeInfo
If Not WScript.Arguments.Count >= 1 Then
	oLogging.ReportFailure strWmessage, iError
End If 
If WScript.Arguments.Named.Exists("High") Then 
	strPwrProfile = strPwrHighPerf
	strPwrProfileLog = "High"
	oLogging.CreateEntry "Power Profile requested to be set: " & strPwrProfileLog, LogTypeInfo
ElseIf WScript.Arguments.Named.Exists("Bal") Then 
	strPwrProfile = strPwrBalanced
	strPwrProfileLog = "Balanced"
	oLogging.CreateEntry "Power Profile requested to be set: " & strPwrProfileLog, LogTypeInfo
Else
	oLogging.ReportFailure strWmessage, iError
End If

'OS Info for Log
oLogging.CreateEntry "Getting information on Operating System", LogTypeInfo
oLogging.CreateEntry "OS Name: " & oEnvironment.Item("OSVERSION"), LogTypeInfo
oLogging.CreateEntry "OS Version: " & oEnvironment.Item("OSCURRENTVERSION"), LogTypeInfo
oLogging.CreateEntry "OS Architecture: " & oEnvironment.Item("Architecture"), LogTypeInfo

'Get OS Arch and set folder to run powerCFG from.
If oEnvironment.Item("Architecture") = "X86" Or oEnvironment.Item("_SMSTSInWinPE") = "true" Or oEnvironment.Item("OSVERSION") = "WinPE" Then
	strPwrCFGFolder = strSystem32
	oLogging.CreateEntry "Using PowerCFG.exe from: " & strPwrCFGFolder & " Folder.", LogTypeInfo
Elseif oEnvironment.Item("Architecture") = "X64" Then
	strPwrCFGFolder = strSysWow64
	oLogging.CreateEntry "Using PowerCFG.exe from: " & strPwrCFGFolder & " Folder.", LogTypeInfo
Else
	oLogging.ReportFailure "Machine Architecture not supported.", iError
End If

'Setting PowerCFG Location
strCMD = strWindir &  "\" & strPwrCFGFolder & "\" & strPwrCFGexe

'Logging Command
oLogging.CreateEntry "PowerCFG Location set to: " & strCMD, LogTypeInfo
oLogging.CreateEntry "Testing Location Available..." & strCMD, LogTypeInfo
iRetVal = oFso.FileExists(strPath)

If iRetVal = Success Then
	oLogging.CreateEntry "Found PowerCFG.exe at Location: " & strCMD, LogTypeInfo
	strCMD =  Chr(34) & strCMD &  Chr(34)
	oLogging.CreateEntry "Building Command to be run", LogTypeInfo
	strCMD = strCMD & strPwrCFGswitch & strPwrProfile
	oLogging.CreateEntry "Final Command to be run: " & strCMD, LogTypeInfo
	'Run PowerCFG
	iRetVal = oUtility.RunWithHeartbeat(strCMD)
	If iRetVal = Success Then
		oLogging.CreateEntry "Successfully set " & strPwrProfileLog & " Performance profile.", LogTypeInfo
		oLogging.CreateEntry "Set-PowerCFG 1.0.0 Complete...", LogTypeInfo
	Else
		oLogging.ReportFailure "Failed to set " & strPwrProfileLog & " Performance profile.", iError
	End If
Else
	oLogging.ReportFailure "Failed to find path: " & strCMD, iError
End If

	</script>
</job>

Cheers,

SCCMOG

Bulk Discover Client Versions

So this morning I was checking up on the status of some client upgrades after installing the latest 1710 hotfix. WMI on each machine had updated to reflect the latest client versions, however most machines hadn’t reported back to ConfigMgr so they were still listed as the older version. Being impatient, I wrote a script that I could use with SCCMs ‘Run Script‘ feature (available as a pre-release feature from version 1706) that would scrape WMI on each machine locally and report back the client version… simple, but awesome!

The script is as follows:

#############################################################
#
#  Author: Jack O'Connor
#  Website: https://github.com/JackOconnor21
#  Modified By: Your name here...
#  Description: Simple script to use on a local machine or via SCCMs
#     'run script' feature to find the client version of a machine
#     in the event SCCM has not yet updated the machine records.
#  
#  Edit the $CurrClientVer variable to reflect the latest client version
#  which is what we will test against.
#
##############################################################

$CurrClientVer = "5.00.8577.1115"
$MyClientVer = (Get-WMIObject -Namespace root\ccm -Class SMS_Client).ClientVersion

If ($MyClientVer -eq $CurrClientVer) {
    Write-Host "Up to date" -ForegroundColor Green
} Else {
    Write-Host "Out of date ($MyClientVer)" -ForegroundColor Red
}

The idea is you add the new client version number into the $CurrClientVer and the script will check WMI on each machine and match the client version against that – if it matches then we get an “Up to date” output, but if it does not we get an “Out of date” output followed by the actual client version on that machine.

You can run this script on any collection you like, I chose to run it on my “System Health | Clients Active” collection, which gave me the feedback pictured below.

 

 

 

 

 

Copyright 2016 SCCMOG | All Rights Reserved