Using Powershell to update an RCDC configuration

I was stuck in one of those loops where you’re trying to track down an error in a RCDC by commenting out sections of the configuration file, uploading, recycling app pool, refreshing your browser, testing, go back to the beginning… I thought “there’s got to be a better way!” – and, as is so often the case, the better way is to write a quick powershell script.

This script updates the ConfigurationData attribute of the named RCDC with the contents of a file. It then recycles the Sharepoint – 80 app pool.

PARAM($RCDCName, $FilePath)

# Get FIMPowershell.ps1 from http://technet.microsoft.com/en-us/library/ff720152(v=ws.10).aspx
. ./FIMPowershell.ps1

# Update Configuration

$content = Get-Content $FilePath

$filter = "/ObjectVisualizationConfiguration[DisplayName = '" + $RCDCName + "']"
$RCDC = export-fimconfig -customconfig ($filter)

$ModifyImportObject = ModifyImportObject -TargetIdentifier $RCDC.ResourceManagementObject.ObjectIdentifier -ObjectType "ObjectVisualizationConfiguration"
SetSingleValue $ModifyImportObject "ConfigurationData" $content
import-fimconfig -importObject $ModifyImportObject

# Recycle App Pool

$AppPool = "W3SVC/APPPOOLS/SharePoint - 80"
$Path = "IISApplicationPool.Name='$AppPool'"

Invoke-WMIMethod Recycle -Path $Path  -Namespace root\MicrosoftIISv2 -Authentication PacketPrivacy

 

The one thing this won’t do is stop that first connection error when you go to test. I tried Thomas’ warm up FIM approach but it didn’t work for me – possibly because I was testing using a different account to the one that had “touched” the Portal.

In case you’re wondering whether I’m so random in my RCDC changes that I couldn’t just back out the last change – it was a transfer of configuration between environments that triggered the error, and actually permissions were at fault, but I didn’t know which permissions until I’d identified the faulty RCDC controls. Somehow two attributes appeared to be in the MPR, but the rights weren’t assigned. I removed and re-added the attributes and then the RCDC worked properly. Some kind of issue with the config migration I guess.

About: Carol

I've been doing IT for 30 years, and IdM for 15. I live in Australia and build IdM solutions based on Microsoft Identity Manager. I also play the violin, but that doesn't help much with the IdM solutions.


Leave a Reply

Your email address will not be published. Required fields are marked *


*