Recently, I worked on an issue to where we had a Synchronization Rule that had become orphaned in the FIM Portal. If a Synchronization Rule becomes orphaned, then:
Our goal here is that we need to discover a way to remove the Synchronization Rule from the FIM Portal without affecting anything else.
To resolve the issue, I put together the following PowerShell script that will loop through the Synchronization Rules and then delete the Synchronization Rule.
POWERSHELL: Deletes a Synchronization Rule
########################################################################################################################
###
### FIM_Support-DeleteSynchronizationRule
######
### PURPOSE: Designed to locate a Synchronization Rule based on DisplayName and/or the ResourceID of the Synchronization Rule
### PARAMETERS:
### $URI = FIM Web Service Address and port ( e.g. http://myfimservice:5725 )
### $GETDISPLAYNAME = Synchronization Rule Display Name of the Synchronization Rule you wish to delete
### $TARGETIDENTIFIER = ResourceID of the Synchronization Rule you wish to delete
PARAM($uri, [string]$GetDisplayName, [string]$TargetIdentifier )
if ( (Get-PSSnapin -Name FIMAutomation -ErrorAction SilentlyContinue) -eq $null ) { Add-PsSnapin FIMAutomation }
$uri = $uri+"/resourcemanagementservice"
$exportData = export-fimconfig -uri $uri -customconfig ("/SynchronizationRule") -onlyBaseResources
$exportData | ForEach-Object{
$displayName = ($_.ResourceManagementObject.ResourceManagementAttributes | `
Where-Object {$_.AttributeName -eq "DisplayName"}).Value
if($displayName -eq $GetDisplayName){
$TargetIdentifier = ((($_.ResourceManagementObject.ResourceManagementAttributes |
Where-Object {$_.AttributeName -eq "ObjectID"}).Value).Split(":"))[2]
}
$importObject = New-Object Microsoft.ResourceManagement.Automation.ObjectModel.ImportObject $importObject.ObjectType = "SynchronizationRule" $importObject.TargetObjectIdentifier = $TargetIdentifier $importObject.SourceObjectIdentifier = $TargetIdentifier $importObject.State = 2 $importObject | Import-FIMConfig -uri $uri -ErrorAction SilentlyContinue
$importObject = New-Object Microsoft.ResourceManagement.Automation.ObjectModel.ImportObject
$importObject.ObjectType = "SynchronizationRule"
$importObject.TargetObjectIdentifier = $TargetIdentifier
$importObject.SourceObjectIdentifier = $TargetIdentifier
$importObject.State = 2
$importObject | Import-FIMConfig -uri $uri -ErrorAction SilentlyContinue