Share via


How to use PowerShell to delete an orphaned Synchronization Rule in FIM

Overview

Recently, we 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:

  1. You will not be able to delete the Synchronization Rule.
  2. You will receive the error message "Unable to process your request" when attempting to view the Properties.

Our goal here is that we need to discover a way to remove the Synchronization Rule from the FIM Portal without affecting anything else.

  • ORPHANED SYNCHRONIZATION RULE: You can get an Orphaned Synchronization Rule if you delete the corresponding Management Agent prior to deleting the Synchronization Rule.

Resolution

To resolve the issue, we put together the following PowerShell script that will loop through the Synchronization Rules and then delete the 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 
}

See Also