How to Use PowerShell to Delete an ExpectedRuleEntry
FIM ScriptBox Item
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 | ||||||||
|
||||||||
Requestors and Operators | ||||||||
|
||||||||
Target Resources | ||||||||
|
Script Code
001 002 003 004 005 006 007 008 009 010 011 012 013 014 015 016 017 018 019 020 021 022 023 024 025 026 027 028 029 030 031 |
#---------------------------------------------------------------------------------------------------------- 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 } #---------------------------------------------------------------------------------------------------------- |
Note
To provide feedback about this script, create a post on the FIM TechNet Forum.
For more FIM related Windows PowerShell scripts, see the FIM ScriptBox.