The script is meant to export the Username, Department, and all security groups that the User is part of. It initially did work for exporting the Username and MemberOf groups – but I tried to add in the department as well to be exported to .csv and it’s now not working for that. Can anyone help me see where I went wrong?
Get-ADUser -Filter * -SearchBase "OU=Users,DC=domain,DC=local" -Properties DisplayName,memberof | % { $Name = $_.DisplayName $_.memberof | Get-ADGroup | Select @{N="User";E={$Name}},Name } | Export-Csv C:Reportsadusrsecgrps.csv -nti
EDIT: I’ve put the original (working) script in. Can anyone tell me what to modify so that I can include the User’s department in the .csv?
submitted by /u/Marquis77
[link] [comments]
The post (Question) – I’m making some kind of small mistake with this Get-User script. appeared first on How to Code .NET.