Share via


FIM: PowerShell to find manager detail of User.

#---------------------------------------------------------------------------------------------------------
# Load FIMAutomation module

 if(@(Get-PSSnapin | ? { $_.Name -eq "FIMAutomation" } ).Count -eq 0)
 {
     Add-PSSnapin FIMAutomation;
 }

Write-Host "User:ManagerDetails"

$users = Export-FIMConfig -customConfig "/Person[(Manager=/Person)]" -Uri "http://localhost:5725"  -OnlyBaseResources
foreach ($user in $users)
{
$x = (($user.ResourceManagementObject.ResourceManagementAttributes | Where-Object {$_.AttributeName -eq "DisplayName"}).Value)
$y = (($user.ResourceManagementObject.ResourceManagementAttributes | Where-Object {$_.AttributeName -eq "Manager"}).Value)

$z=$y.replace("urn:uuid:","")

$Manager=Export-FIMConfig -customConfig "/Person[ObjectID='$z']" -Uri "http://localhost:5725"  -OnlyBaseResources

$ManagerDetails = (($Manager.ResourceManagementObject.ResourceManagementAttributes | Where-Object {$_.AttributeName -eq "DisplayName"}).Value)

Write-Host "$x :$ManagerDetails"

}
#---------------------------------------------------------------------------------------------------------