Thursday, April 25, 2024

Simple AD Search with Powershell Get-ADUser

 I needed to do a quick search in AD for a user this morning.  I wrote this script, hope it helps someone.

Clear-Host
Clear-History

$ADFilter = Read-Host -prompt "Search AD "
Get-ADUser -Filter {(Surname -like $ADFilter) -or (GivenName -like $ADFilter)} -Properties *
    | Select-Object DisplayName, samAccountName, EmailAddress
    | Format-Table -AutoSize

No comments:

Post a Comment

Checking Backup File Date Before Restoring

 Today, I got an interesting request.  I had to check a restore job for a data warehouse analyst.  He said the database wasn't restored ...