2018-10-11

Change SCCM Offline Servicing location (with powershell)


There is plenty google results for how to change SCCM Offline Servicing location, but most of those that I've checked involve using wbemtest.exe, I wanted a way to do that with powershell, so here it is:

#your SCCM Site Name
$SiteName = "ITO" 
#the drive where you want offlince servicing to happen
$TargetDrive = "D:"

$CimInstance = Get-CimInstance -Namespace root/SMS/site_$SiteName -ClassName SMS_SCI_Component -Filter "SiteCode='$SiteName' and ItemName like 'SMS_OFFLINE_SERVICING_MANAGER%'"
($CimInstance.Props | Where-Object {$_.PropertyName -eq "StagingDrive"}).Value1 = $TargetDrive
Set-CimInstance -CimInstance $CimInstance -PassThru

Links:
https://techcommunity.microsoft.com/t5/Enterprise-Mobility-Security/Customizing-Offline-Servicing-of-Operating-System-Images/ba-p/247778
https://docs.microsoft.com/en-us/powershell/module/cimcmdlets/get-ciminstance?view=powershell-6
https://docs.microsoft.com/en-us/powershell/module/cimcmdlets/set-ciminstance?view=powershell-6