This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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]@{ |