Thursday, July 11, 2013

Powershell script to enable command-shell in winPE 3.1 boot images for use in ConfigMgr 2012 R2

Following Brandon Linton's post about creating and importing a WinPE 3.1 boot image for use in ConfigMgr 2012 SP1 CU2, below is a little Powershell script to enable command-shell


#CM2012 R2 - Enable Command-Shell in WinPE 3.1 Boot Image

#Replace below OSDxxxxx with your boot image package ID
$BootImagePackageID = "OSDxxxxx" 

#Get the Boot image - Replace OSD by your site code
$BootImageQuery = Get-WmiObject -Namespace "Root\SMS\Site_OSD" -Class SMS_BootImagePackage -Filter "PackageID='$BootImagePackageID'"

#Read Properties
$BootImageQuery.Get()

#Enable Command-Shell
$BootImageQuery.EnableLabShell = 'True'
$BootImageQuery.Put()

#Update Distribution Points
$BootImageQuery.RefreshPkgSource()