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

Little script to see the backup history

 Today, I was teaching a co-worker how to create a copy only backup of a SQL Managed Instance database.  And I came up to use this script t...