INTRODUCTION¶
PowerShell, released by Microsoft in 2006, is a powerful upgrade to Command Prompt. It includes access to cmdlets (pronounced command-lets), which are .NET classes designed to perform specific functions. This cheat sheet focuses on using PowerShell for Active Directory (AD) enumeration, leveraging cmdlets included with the AD-RSAT (Active Directory Remote Server Administration Tools) package.
ENUMERATING AD USERS¶
-
Enumerates AD users and retrieves properties of AD user objects.
Get-ADUser -Identity gordon.stevens -Server za.example.com -Properties *
-
Use filters to narrow down the user search.
Get-ADUser -Filter 'Name -like "*Roland"' -Server za.example.com | Format-Table Name,SamAccountName -A
-
Lists all users in the AD.
Get-ADUser -Filter * -Server za.example.com | Format-Table Name,SamAccountName -AutoSize
ENUMERATING AD GROUPS¶
-
Enumerates AD groups.
Get-ADGroup -Identity Administrators -Server za.example.com
-
Enumerate group membership using the Get-ADGroupMember cmdlet.
Get-ADGroupMember -Identity Administrators -Server za.example.com
-
Lists all groups in the AD.
Get-ADGroup -Filter * -Server za.example.com | Format-Table Name,GroupScope -AutoSize
ENUMERATING AD COMPUTERS¶
-
Enumerates AD computers.
Get-ADComputer -Identity "DC01" -Server za.example.com -Properties *
-
Use filters to narrow down the computer search.
Get-ADComputer -Filter 'OperatingSystem -like "*Server*"' -Server za.example.com | Format-Table Name,OperatingSystem -A
-
Lists all computers in the AD.
Get-ADComputer -Filter * -Server za.example.com | Format-Table Name,OperatingSystem -AutoSize
ENUMERATING AD OBJECTS¶
-
Performs generic searches for any AD objects.
$ChangeDate = New-Object DateTime(2024, 05, 25, 12, 00, 00)
Get-ADObject -Filter 'whenChanged -gt $ChangeDate' -IncludeDeletedObjects -Server za.example.com
-
Lists all AD objects.
Get-ADObject -Filter * -Server za.example.com | Format-Table Name,ObjectClass -AutoSize
ENUMERATING DOMAINS¶
- Retrieves additional information about the specific domain.
Get-ADDomain -Server za.example.com
- Retrieves information about organizational units.
Get-ADOrganizationalUnit -Filter * -Server za.example.com | Format-Table Name,DistinguishedName -A