Home Linux & Systems Cybersecurity Cloud & DevOps Networks & Infrastructure SIEM & Monitoring DFIR & Threat Intel Development & Other All categories Projects About Tools

Script to list the users and groups they belong to in Active Directory using Powershell

Leer en espanol
Script to list the users and groups they belong to in Active Directory using Powershell

Table of contents

Get-ADUser -Filter * -Prop ===

This time we are going to see a small script which allows you to obtain a report of all the users of your domain controller and the group that those users belong to:

Get-ADUser -Filter * -Properties DisplayName, memberof | % {
New-Object PSObject -Property @{
UserName = $_.DisplayName
Groups = ($_.memberof | Get-ADGroup | Select -ExpandProperty Name) -join «,»
}
} | Select UserName,Groups | Export-Csv C:\report.csv -NTI

Comments