windows_ad Commands

User Management

Get-ADUser

Gets one or more Active Directory users.

Get-ADUser

Examples:
Get a specific user by their SAM account name
Get-ADUser -Identity 'jdoe'
Get all users in a specific OU
Get-ADUser -Filter * -SearchBase 'OU=Finance,DC=example,DC=com'
Get all enabled users and show their email addresses
Get-ADUser -Filter 'Enabled -eq $true' -Properties EmailAddress | Select-Object Name, EmailAddress
Set-ADUser

Modifies an Active Directory user.

Set-ADUser

Examples:
Set the description for a user
Set-ADUser -Identity 'jsmith' -Description 'Accountant'
Disable a user account
Set-ADUser -Identity 'jdoe' -Enabled $false
Clear the manager property for a user
Set-ADUser -Identity 'jdoe' -Clear 'manager'
New-ADUser

Creates a new Active Directory user.

New-ADUser

Examples:
Create a new user with a password prompt
New-ADUser -Name 'Jane Doe' -SamAccountName 'jdoe' -AccountPassword (Read-Host -AsSecureString 'Enter password:') -Path 'OU=Users,DC=example,DC=com' -Enabled $true
Remove-ADUser

Removes an Active Directory user.

Remove-ADUser

Examples:
Remove a user with confirmation
Remove-ADUser -Identity 'jdoe'

Computer Management

Get-ADComputer

Gets one or more Active Directory computers.

Get-ADComputer

Examples:
Get a specific computer object
Get-ADComputer -Identity 'SERVER01'
Get all computers with 'server' in their name
Get-ADComputer -Filter 'Name -like "*server*"'

Group Management

Get-ADGroup

Gets one or more Active Directory groups.

Get-ADGroup

Examples:
Get a specific group
Get-ADGroup -Identity 'Domain Admins'
Get all security groups
Get-ADGroup -Filter 'GroupCategory -eq "Security"'
Get-ADGroupMember

Gets the members of an Active Directory group.

Get-ADGroupMember

Examples:
Get members of the 'Domain Admins' group
Get-ADGroupMember -Identity 'Domain Admins'
Recursively get all members of a group
Get-ADGroupMember -Identity 'All-Staff' -Recursive
Add-ADGroupMember

Adds one or more members to an Active Directory group.

Add-ADGroupMember

Examples:
Add a user to a group
Add-ADGroupMember -Identity 'Finance Users' -Members 'jdoe'
Add multiple users to a group
Add-ADGroupMember -Identity 'Marketing' -Members 'jsmith','bsmith'

Ou Management

Get-ADOrganizationalUnit

Gets one or more Active Directory organizational units.

Get-ADOrganizationalUnit

Examples:
Get all OUs in a domain
Get-ADOrganizationalUnit -Filter *