blog.icewolf.ch

Let's talk about IT!
posts - 2141, comments - 295, trackbacks - 0

My Links

Archives

Post Categories

icewolf

Search Active Directory with Powershell

Hallo zusammen

Wie einfach es ist mit Powershell die AD zu durchsuchen habe ich in dem folgenden kleinen Script dokumentiert.

$SearchVal = "a.bohren"
$resolve = "(|(sAMAccountName=$SearchVal)(cn=$SearchVal)(displayName=$SearchVal)(givenName=$SearchVal)(employeeID=$SearchVal))"
$filter = "(&(objectCategory=Person)(objectClass=User)$resolve)"
   
$searcher = New-Object System.DirectoryServices.DirectorySearcher $filter
$searcher.PageSize = 1000
$searcher.SearchScope = "Subtree"

$userlist = $searcher.FindAll()
write-host "Found: " $userlist.count
$userlist

Grüsse
Andres Bohren

Print | posted on Thursday, April 7, 2011 10:16 PM | Filed Under [ PowerShell ]

Powered by:
Powered By Subtext Powered By ASP.NET