CODE – PowerShell get user object info

Get user object information for Active Directory

This code demonstrates how to search and retrieve User Object information from Active Directory without any plug-ins.
To run this script within your environment you should only need to copy and paste this script into either Windows Powershell ISE with the following changes to the script which I have numbered below.
Change the line, ($strUserName = “samAccountName”), so that you have a real User ID.
You can also search in a specific Active Directory OU By changing the second line of code
From: “$objDomain = New-Object System.DirectoryServices.DirectoryEntry”
To: “$objDomain = New-Object System.DirectoryServices.DirectoryEntry(“LDAP://OU=ASDF,DC=asdf,DC=asdf”)”

Comments

comments

Leave a Reply