Wednesday 12 February 2014

Handy Powershell script to query AD for any object

I believe keeping this handy and simple PowerShell script within reach is a good idea to query your Active Directory (AD) quickly with a hint of name. It will return you objects that have your wildcard in it. Quick way find things before digging more.
param(
[Parameter(Mandatory=$true,Position=1)][string]$Query
)
$filter = "anr=$Query"
$dc = "YourDC:3268"
Get-ADObject -LDAPFilter $filter -Server $dc

Usage


.\Get-Something01.ps1   osxx

Output









































DistinguishedNameNameObjectClassObjectGUID
CN=Osman SHENER,…Osman SHENERuser2c973a30-4e…
CN=osxxNOT01,OU=…osxxNOT01computer840e9c35-4d…
CN=osxxOSDW7TEST…osxxOSDW7TEST20computerafe1c1fe-41…
CN=osxxPC01,OU=W…osxxDSK01computer3db219e1-44…
CN=osxxVM,OU=San…osxxVMcomputerecefbb2f-44…

No comments:

Post a Comment