Colin Cochrane

Colin Cochrane is a Software Developer based in Victoria, BC specializing in C#, PowerShell, Web Development and DevOps.

Searching Active Directory using PowerShell

I recently discovered a very convenient way to search Active Directory using the [adsisearcher] type accelerator. Here’s a simple example searching for a user based on their first and last names:

$searcher = [adsisearcher]""
$searcher.Filter = "(&(givenName=Pete)(sn=Peterson))"
$user = [adsi]($search.FindOne().Path)