By David Wiseman (Administrator)Created 04 Mar 2008
My Rating:
Vote
Rating:
Not Rated
Views:16126
Downloads:153

Search for a User with a Specified SAMAccountName

Language:  PowerShell

Compatibility

Windows XP Yes Windows 2003 Yes
Windows 2000 No Windows NT No
Vista Unknown Windows 2008 Unknown
Description

Sample script that searches Active Directory for a user with the sAMAccountName kenmyer. The sAMAccountName attribute is replicated to the Global Catalog. This means you can connect to a Global Catalog server and search across the forest for a SAM Account Name.

Code

Line Numbers: On  Off      Plain Text
$strFilter = "(&(objectCategory=User)(sAMAccountName=kenmyer))"

$objDomain = New-Object System.DirectoryServices.DirectoryEntry

$objSearcher = New-Object System.DirectoryServices.DirectorySearcher
$objSearcher.SearchRoot = $objDomain
$objSearcher.PageSize = 1000
$objSearcher.Filter = $strFilter

$colProplist = "name"
foreach ($i in $colPropList){$objSearcher.PropertiesToLoad.Add($i)}

$colResults = $objSearcher.FindAll()

foreach ($objResult in $colResults)
    {$objItem = $objResult.Properties; $objItem.name}

 


Got a useful script? Click here to upload!


 

  Post Comment
Order By:  
User Comments
      
qzyfffff
Posted On: 1/12/2019 8:22:55 AM

offwhite yeezy boost 350 yeezy 500 vans outlet replica rolex jordans balenciaga adidas shoes jordan 6 adidas ultra boost westbrook shoes adidas tubular shadow chrome hearts nike flyknit racer michael kors outlet nfl jerseys cheap nba jerseys off white shoes jordan shoes michael kors handbags balenciaga fila nike air max 2018 fila shoes cheap nfl jerseys nike air max 2017 adidas yeezy fila disruptor nike air huarache curry 4 shoes golden goose outlet golden goose fila nike hyperdunk hermes handbags bag yeezy hermes handbags for sale goyard crazy explosive coach handbags nike sneakers for men kyrie irving shoes pandora bracelet off white fake rolex michael kors handbags kobe sneakers moncler jackets cheap jordans nike react yeezy boost 350 golden goose outlet adidas tubular nike kd 11 nike react louboutin shoes balenciaga triple s yeezy boost 350 v2 yeezy boost 350 v2 adidas shoes outlet off white clothing jordan shoes adidas stan smith sneakers adidas nmd r1 lebron 16 nike flyknit nike polo shirts kd shoes kd 11 lebron 16 shoes nike cortez men nfl store red bottoms hermes handbags lebron 16 shoes james harden shoes yeezy boost 350 golden goose outlet michael kors outlet online goyard bag air max 2019 adidas ultra boost uncaged lacoste online shop goyard handbags cat boots goyard bag balenciaga nike air max lebron 11 hermes belt michael kors handbags tory burch shoes nike huarache air max 270 hermes belts for men adidas tubular balenciaga shoes yeezy boost 350 coach outlet caterpillar boots adidas ultra boost fake rolex hogan outlet online golden goose kate spade handbags air jordan 4 yeezy shoes nike shoes red bottom shoes lacoste polo kd shoes lebron james shoes timberland outlet nike sneakers for women nike air max 90 yeezy shoes yeezy shoes curry 5 yeezy shoes adidas nmd off white adidas yeezy kobe shoes off white nike ultra boost fila shoes yeezy shoes fitflops gucci belt yeezy nhl jerseys timberland boots yeezy kd shoes yeezy boost 350 nike epic react hermes belt hermes birkin golden goose sneakers nike vapormax kevin durant shoes adidas zx flux adidas pure boost yeezy boost polo ralph lauren air jordan supreme hoodie valentino shoes nike cortez nike lebron 16 kd 11 shoes asics shoes vapormax jimmy choo shoes chrome hearts coach factory outlet kobe byrant shoes birkin bag adidas stan smith michael kors outlet online michael kors nike air max 2019 nike polo nike shox nike roshe run lacoste outlet adidas crazy explosive michael kors handbags fila shoes goyard handbags mbt shoes curry 4 jordan shoes mbt shoes online coach outlet online fila sneakers off white hoodie yeezy boost 350 v2 calvin klein outlet yeezys cheap jordans adidas tubular longchamp outlet basketball shoes kyrie 3 retro jordans links of london yeezy boost 350 michael kors purses yeezy boost lacoste outlet adidas gazelle yeezy boost 700 air yeezy chrome hearts online curry 4 lebron shoes asics running shoes goyard handbags nike foamposite coach outlet sale air max 2018 hermes belt kyrie 4 shoes jordan retro 6 adidas superstars goyard bags cheap nba jerseys hermes outlet online michael kors outlet air jordans russell westbrook shoes yeezy boost 350 v2 hermes bags jordan 12 lacoste polo shirts longchamp handbags fitflops sale clearance yeezys longchamp kd 10 birkin bag ralph lauren uk jordan 4 golden goose sneakers ysl handbags lacoste polo converse outlet store nike air max nmd valentino ysl longchamp bags converse outlet harden shoes adidas stan smith shoes adidas eqt support yeezy boost fila hogan outlet nike basketball shoes nike air max goyard canada goose jacket coach factory outlet yeezy boost paul george shoes nike epic react retro jordans iniki bape hoodie moncler jacket nike air max jordan shoes cheap mlb jerseys adidas yeezy adidas outlet online canada goose fila yeezy boost 350 air jordan curry 5 balenciaga shoes nike air max 270 stephen curry 5 golden goose nike roshe calvin klein outlet online michael kors outlet michael kors outlet online rolex replica bape hoodie ferragamo belt yeezy boost 350 michael jordan shoes michael kors handbags off white hoodie nike shox for men jordans red bottom heels coach outlet kobe 9 goyard bags ralph lauren uk nmd michael kors outlet hermes online shop jordan retro pure boost golden goose outlet adidas outlet balenciaga shoes fake rolex watches balenciaga sneakers nike air force 1 coach outlet chrome hearts online jordan shoes adidas iniki coach outlet yeezy boost gucci belts golden goose sneakers kd 11 stephen curry 5 nike huarache air jordan 13 birkin bag coach outlet sale goyard wallet michael kors handbags lebron shoes ferragamo belt vans shoes michael kors outlet jordan 13 adidas yeezy boost fila shoes ferragamo belts tory burch outlet nike sneakers kobe 9 lebron 10 yeezy boost 350 v2 lebron 16 adidas shoes online yeezy shoes yeezy boost 500 michael kors jordan 11 cheap jordans links of london outlet store nike max lebron 15 shoes supreme hoodie hermes handbags off white clothing goyard st louis tot reebok outlet air max 90 chrome hearts moncler jackets nike jordans jordan sneakers off white x jordan 1 golden goose sneakers yeezy boost golden goose michael kors factory outlet adidas stan smith nba jerseys coach outlet online adidas superstar golden goose tory burch off white shoes adidas yeezy tory burch sandals yeezy boost 350 yeezy 700 jordans lacoste adidas nmd kyrie 4 golden goose adidas nmd cheap jordans air force 1 yeezy boost kobe basketball shoes birkin bag golden goose outlet michael kors uk reebok shoes jordan 11 retro baseball jerseys 100% real jordans for cheap adidas nmd runner supreme clothing nike air force lebron 16 ferragamo belts louboutin shoes uk moncler outlet jordan retro 12 Kanye West shoes lebron 15 air max christian louboutin off white lacoste polo yeezy shoes michael kors handbags outlet zx flux yeezy boost 350 v2 pandora jewelry kobe 11 adidas eqt kyrie shoes adidas ultra kobe 11 off white clothing yeezy 500 mbt shoes outlet chrome hearts online kobe shoes off white jordan 1 michael kors outlet mlb jerseys