Getting ManagedBy information to populate and write to file.

%3CLINGO-SUB%20id%3D%22lingo-sub-2280664%22%20slang%3D%22en-US%22%3EGetting%20ManagedBy%20information%20to%20populate%20and%20write%20to%20file.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2280664%22%20slang%3D%22en-US%22%3E%3CP%3EI'm%20running%20the%20following%20script.%20Goal%20is%20to%20get%20a%20CSV%20that%20shows%20a%20list%20of%20users%20and%20the%20persons%20name%20that%20is%20entered%20in%20the%20ManagedBy%20tab%20for%20the%20group%20the%20user%20is%20a%20member%20of.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%24users%20%3D%20Get-ADUser%20-Filter%20'(Description%20-like%20%22Vendor%22)'%3CBR%20%2F%3E%3CBR%20%2F%3E%24report%20%3D%20foreach%20(%24user%20in%20%24users)%20%7B%3CBR%20%2F%3E%26nbsp%3B%20%26nbsp%3B%20%5BPSCustomObject%5D%40%7B%3CBR%20%2F%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20User%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%3D%20%24user.Name%3CBR%20%2F%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%24Group%20%3D%20%7BGet-ADGroup%20-Filter%20*%20-Properties%20ManagedBy%20-SearchBase%20%22OU%3DGroups%2COU%3DEnterprise%20Support%2CDC%3Dventasmob%2CDC%3Dlocal%22%20%7D%20%7C%3CBR%20%2F%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20Select%20%24Group.ManagedBy%20%7C%3CBR%20%2F%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20Sort%20-Property%20MAnagedBy%3CBR%20%2F%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%7D%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%3CBR%20%2F%3E%24report%20%7C%20Export-CSV%20-path%20c%3A%5CBAS%5Cuserlisty.csv%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20outcome%20looks%20like%20tis%3A%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22mikemitschkemikeMits_0-1619034437058.png%22%20style%3D%22width%3A%20724px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F274407iB25EC65B6B0E7A29%2Fimage-dimensions%2F724x134%3Fv%3Dv2%22%20width%3D%22724%22%20height%3D%22134%22%20role%3D%22button%22%20title%3D%22mikemitschkemikeMits_0-1619034437058.png%22%20alt%3D%22mikemitschkemikeMits_0-1619034437058.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2280664%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EWindows%20PowerShell%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2280863%22%20slang%3D%22en-US%22%3ERe%3A%20Getting%20ManagedBy%20information%20to%20populate%20and%20write%20to%20file.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2280863%22%20slang%3D%22en-US%22%3E%3CP%3EHello%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1030732%22%20target%3D%22_blank%22%3E%40mikemitschkemikeMits%3C%2FA%3E%2C%3C%2FP%3E%3CP%3ECan%20you%20please%20provide%20more%20details%3F%3C%2FP%3E%3CP%3EWhat%20you%20need%20to%20get%20in%20the%20resulting%20csv%3F%3C%2FP%3E%3CP%3EList%20of%20users%20and%20where%20does%20his%20name%20is%20mentioned%20in%20Managed%20by%3F%3C%2FP%3E%3CP%3EUser%2C%20IsManagedByGroup%3C%2FP%3E%3CP%3EMister%20Test%2C%20GroupOne%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Visitor

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:

mikemitschkemikeMits_0-1619034437058.png

 

1 Reply

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.