Skip to content

Instantly share code, notes, and snippets.

View TheChrisRoss's full-sized avatar
🎯
Focusing

Chris Ross TheChrisRoss

🎯
Focusing
View GitHub Profile
# Define the domain and the Organizational Unit (OU) or container to search
$Domain = "Domain.local"
$OU = "OU=Users,OU=OrgName,DC=Domain,DC=local"
# Get the users from the specified OU
$Users = Get-ADUser -Filter * -SearchBase $OU -Property GivenName,Surname,SamAccountName,Enabled
# Loop through each user and display their details
$Users | ForEach-Object {
[PSCustomObject]@{