Thursday, 8 May 2014

Powershell to find User details from AD

Seen a computername hitting your databases not sure who it is.  This will help you find the owner information of the computer.  Enter the PC name, and it will show the details stored in AD under owner.


= "Quit"




= Read-Host "Please supply computer to lookup"


= "(&(objectCategory=Computer)(name="+$machine+"))"


= New-Object System.DirectoryServices.DirectoryEntry


= New-Object System.DirectoryServices.DirectorySearcher


.SearchRoot = $objDomain


.PageSize = 1000


.Filter = $strFilter


.SearchScope = "Subtree"


= "name", "description"


($i in $colPropList){$objSearcher.PropertiesToLoad.Add($i)}


= $objSearcher.FindAll()


($objResult in $colResults)

$objItem = $objResult.Properties; $; $objItem.description}



= Read-Host "Are you sure you want to quit application? (Y/N)"}

until ($strResponse -eq "Y")

No comments:

Post a Comment

Your views:-