Forum Discussion

mikemitschkemikeMits's avatar
mikemitschkemikeMits
Copper Contributor
Apr 21, 2021

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:

 

  • AndySvints's avatar
    AndySvints
    Steel 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.

     

Resources