Quantcast
Channel: Forum Microsoft Identity Manager
Viewing all articles
Browse latest Browse all 6944

Using PowerShell to delete an ExpectedRuleEntry

$
0
0
 Summary
 

The script code below deletes an ExpectedRuleEntry object from your environment.
To run this script, you need to configure a Management Policy Rule that grants you permission to perform this operation:

 

Management Policy Rule Configuration
NameAdministration: Administrators can delete Expected Rule Entries
TypeRequest
Grants PermissionsTrue
DisabledFalse
Requestors and Operators
RequestorAdministrators
OperationDelete
Target Resources
Before RequestAll expected rule resources
After Request(Attribute)
Resources AttributesAll Attributes

 

 

#----------------------------------------------------------------------------------------------------------
 set-variable -name URI -value "http://localhost:5725/resourcemanagementservice" -option constant
#----------------------------------------------------------------------------------------------------------
 If(@(get-pssnapin | where-object {$_.Name -eq "FIMAutomation"} ).count -eq 0) {add-pssnapin FIMAutomation}

 if($args.count -ne 1) {throw "Missing GUID parameter"}
 $objectGUID = $args[0]
 $exportObject = export-fimconfig -uri $URI `–onlyBaseResources `
                                  -customconfig "/ExpectedRuleEntry[ObjectID='$objectGUID']" `
                                  -ErrorVariable Err `
                                  -ErrorAction SilentlyContinue 
 If($Err){Throw $Err}
 If($exportObject -eq $null) {throw "ERE not found"}

 $ImportObject = New-Object Microsoft.ResourceManagement.Automation.ObjectModel.ImportObject
 $ImportObject.ObjectType = "ExpectedRuleEntry"
 $ImportObject.TargetObjectIdentifier = (($exportObject.ResourceManagementObject.ObjectIdentifier).split(":"))[2]
 $ImportObject.SourceObjectIdentifier = (($exportObject.ResourceManagementObject.ObjectIdentifier).split(":"))[2]
 $ImportObject.State = 2 
 $ImportObject | Import-FIMConfig -uri $URI -ErrorVariable Err -ErrorAction SilentlyContinue 
 If($Err){Throw $Err}
 Write-Host "`nCommand completed successfully`n"
#----------------------------------------------------------------------------------------------------------
 trap 
 { 
    Write-Host "`nError: $($_.Exception.Message)`n" -foregroundcolor white -backgroundcolor darkred
    Exit 1
 }
#----------------------------------------------------------------------------------------------------------

 

 Go to the FIM ScriptBox

Markus Vilcinskas, Knowledge Engineer, Microsoft Corporation

Viewing all articles
Browse latest Browse all 6944

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>