I'm trying to make a report for some managers that shows who is listed as the "Managedby" for a list of groups. Not every group has a managedby listed. The groups are in different domains or child domains. The user (or group) in the managedby attribute for the group could be in a different domain as well. Now the following script works great for getting the information:
$results = @() $groups = Get-Content "C:\Temp\Groups.txt" ForEach($group in $groups) { $results += Get-ADObject -Server "GlobalCatalog.Server.com:3268" -Filter {name -eq $group} -property msDS-PrincipalName, name, managedby, whenCreated, whenChanged, description, info| Select-Object msDS-PrincipalName, name, managedby, whenCreated, whenChanged, description, info }$results| export-csv "C:\Temp\Groups-info.csv" -NoTypeInformation
My isssue is the "Managedby" attribute is a DN value, not real Non-techincal manager real reader friendly. I'm trying to format the Managedby attribute into something more reader friendly. Does anyone have any ideas? I have been trying something like the following but with no luck. Really any and all help is appreciated
$results = @() $groups = Get-Content "C:\Temp\Groups.txt" ForEach($group in $groups) { $results += Get-ADObject -Server "GC.Server.com:3268" -Filter {name -eq $group} -property msDS-PrincipalName, name, managedby, whenCreated, whenChanged, description, info| ForEach-Object{ $ManagedByName = Get-ADObject -Server "GC.Server.com:3268" -Filter {$results.managedby} -Properties cn $ManagedByNTID = Get-ADObject -Server "GC.Server.com:3268" -Filter {$results.managedby} -Properties msDS-PrincipalName $ManagedByObjClass = Get-ADObject -Server "GC.Server.com:3268" -Filter {$results.managedby} -Properties ObjectClass }|Select-Object msDS-PrincipalName, name, managedby, $ManagedByName, $ManagedByNTID, $ManagedByObjClass, whenCreated, whenChanged, description, info } $results| export-csv "C:\Temp\Groups-info.csv"