Showing posts with label OSD. Show all posts
Showing posts with label OSD. Show all posts

Friday, September 6, 2013

Powershell Script to delete all elements in Configuration Manager client cache

You may need to delete all elements in Configuration Manager client cache. Here it is in a Powershell way:

#Delete all elements in Configuration Manager client cache

$CMObject = New-Object -ComObject "UIResource.UIResourceMgr"
$CMCacheObjects = $CMObject.GetCacheInfo()
$CMCacheElements = $CMCacheObjects.GetCacheElements()

Foreach ($CacheElement in $CMCacheElements) 
    {
    $CMCacheObjects.DeleteCacheElementEx($CacheElement.CacheElementID)
    } 

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()