Using PowerShell to display the value of the ERL attribute of a user
Summary
To synchronize an object to a target data source, the object must have a populated ERL attribute.The values of this attribute are used by the synchronization engine to locate the appropriate outbound synchronization rules that need to be applied to an object during a synchronization run.The script code below displays the value of a user.When calling the script, you need to provide the display name of the object as parameter.
#----------------------------------------------------------------------------------------------------------
set-variable -name URI -value "http://localhost:5725/resourcemanagementservice" -option constant
#----------------------------------------------------------------------------------------------------------
function ShowEREName
{
PARAM($objectId)
END
{
$exportObject = export-fimconfig -uri $URI `
–onlyBaseResources `
-customconfig "/ExpectedRuleEntry[ObjectID='$objectId']"
if($exportObject -eq $null) {write-host " -$($objectId)"}
else
{
$displayName = $exportObject.ResourceManagementObject.ResourceManagementAttributes | `
Where-Object {$_.AttributeName -eq "DisplayName"}
$status = $exportObject.ResourceManagementObject.ResourceManagementAttributes | `
Where-Object {$_.AttributeName -eq "SynchronizationRuleStatus"}
write-host " -$($displayName.Value), $($status.Value)"
}
}
}
#----------------------------------------------------------------------------------------------------------
if($args.count -ne 1) {throw "Missing name parameter"}
$objectName = $args[0]
write-host $objectName
if(@(get-pssnapin | where-object {$_.Name -eq "FIMAutomation"} ).count -eq 0) {add-pssnapin FIMAutomation}
$exportObject = export-fimconfig -uri $URI `
–onlyBaseResources `
-customconfig "Person[DisplayName='$objectName']"
if($exportObject -eq $null) {throw "L:Object not found"}
$erlAttribute = $exportObject.ResourceManagementObject.ResourceManagementAttributes | `
Where-Object {$_.AttributeName -eq "ExpectedRulesList"}
if($erlAttribute -eq $null) {throw "L:The expected rules list doesn't have values"}
foreach($erlValue in $erlAttribute.values) {ShowEREName -objectId ($erlValue.split(":"))[2]}
write-host "`n"
#----------------------------------------------------------------------------------------------------------
trap
{
$exMessage = $_.Exception.Message
if($exMessage.StartsWith("L:"))
{write-host "`n" $exMessage.substring(2) "`n" -foregroundcolor white -backgroundcolor darkblue}
else {write-host "`nError: " $exMessage "`n" -foregroundcolor white -backgroundcolor darkred}
Exit
}
#----------------------------------------------------------------------------------------------------------
Go to the FIM ScriptBox
November 5th, 2009 3:21am
I've added the ERE status to the PowerShell script.Here is the related VBScript:
Option Explicit
Dim userName, oShell, appCmd
userName = InputBox ("User Name", "Get ERL for user")
If(0 = Len(userName)) Then
WScript.Quit
End If
Set oShell = CreateObject("WScript.Shell")
appCmd = "powershell -noexit &'" & Replace(WScript.ScriptFullName, ".vbs", ".ps1") & "' '" & userName & "'"
oShell.Run appCmd, 4, false
Markus Vilcinskas, Knowledge Engineer, Microsoft Corporation
Free Windows Admin Tool Kit Click here and download it now
January 7th, 2010 6:57pm