Hello, everyone!
Welcome back to our blog series on automation and API capabilities within Microsoft Configuration Manager. In our previous post, we delved into the Windows Management Instrumen...
I assume with Upgrade you mean you did an Disaster-Recovery and point the Installation to a new Directory. Yes, I had a few times such cases. Still my advice to open a case. So you have a similar situation like this:
But to your question - a change for this would look like that - the CodeSnip is pretty old (6 years) - but it is still working:
# Parameters
$SiteServer = "PFECM001"
$sitecode = "LAB"
$scfNamespace = "root\SMS\site_$sitecode"
$RoleName = "SMS Site Server"
$OldNALPath = '["Display=\\PFECM001.LAB.LOCAL\E$\Roles\ConfigMgr\"]MSWNET:["SMS_SITE=LAB"]\\PFECM001.LAB.LOCAL\E$\Roles\ConfigMgr\'
$NewNALPath = '["Display=\\PFECM001.LAB.LOCAL\D$\Roles\ConfigMgr\"]MSWNET:["SMS_SITE=LAB"]\\PFECM001.LAB.LOCAL\D$\Roles\ConfigMgr\'
# Find the SMS Site Server Role - Check the PropList Value and Create an new SMS_EmbeddedPropertyList if match
$resources = Get-WmiObject -namespace $scfNamespace -query "Select * From SMS_SCI_SysResUse Where SiteCode='$sitecode' and RoleName='$RoleName'"
foreach ($res in $resources)
{
foreach ($Prop in $res.PropLists)
{
Write-host $Prop.PropertyListName
Write-Host $Prop.Values
If ($Prop.Values = $OldNALPath)
{
Write-Host "Match found"
$embeddedpropertylist_class = [wmiclass]""
$embeddedpropertylist_class.psbase.Path = "\\$SiteServer\root\sms\site_$($sitecode):SMS_EmbeddedPropertyList"
$embeddedpropertylist = $embeddedpropertylist_class.createInstance()
$embeddedpropertylist.PropertyListName=$Prop.PropertyListName
$embeddedpropertylist.Values = $NewNALPath
}
}
}
$resources.PropLists = $embeddedpropertylist
$resources
$resources.Put()
Nowadays you can create the Embedded-Objects also with a CmdLet. Take out or comment out the $resources.Put() then you can compare the result.