Forum Discussion
Getting ManagedBy information to populate and write to file.
I'm running the following script. Goal is to get a CSV that shows a list of users and the persons name that is entered in the ManagedBy tab for the group the user is a member of.
$users = Get-ADUser -Filter '(Description -like "Vendor")'
$report = foreach ($user in $users) {
[PSCustomObject]@{
User = $user.Name
$Group = {Get-ADGroup -Filter * -Properties ManagedBy -SearchBase "OU=Groups,OU=Enterprise Support,DC=ventasmob,DC=local" } |
Select $Group.ManagedBy |
Sort -Property MAnagedBy
}
}
$report | Export-CSV -path c:\BAS\userlisty.csv
The outcome looks like tis:
- AndySvintsSteel Contributor
Hello mikemitschkemikeMits,
Can you please provide more details?
What you need to get in the resulting csv?
List of users and where does his name is mentioned in Managed by?
User, IsManagedByGroup
Mister Test, GroupOne
Thank you.