QUICKBlog: Changing AD User’s properties – There’s the PowerShell or a third-party custom way…

The good thing about PowerShell is that it can build from scratch your scripts, and you learn a lot in the process.  But, there’s a lot of good third-party products, such as Quest PowerGUI, that can give you a productive series of Cmdlets.  In this QuickBlog, I will show the long way (but still short) to get and update a User properties in Active Directory.

First, I will use PowerShell script with no additional third-party cmdlets. It’s a slightly longer route due to the fact that I want trap the individual ADSI Path for the User I’m going to change one of the property.

#Here's the long way using Get-WMIObject:
$GetUsers = Get-WmiObject -NameSpace "root\directory\LDAP" -class ads_user
$uPath = $GetUsers | ? {$_.ds_name -eq 'MaxRTrinidad'}
#Will store ADSIpath = LDAP://CN=MaxRTrinidad,OU=Users,OU=Developers,OU=IT Group,OU=MyCity,DC=MyADdoman,DC=COM
## - To display all the ADSI objects in your variables remember to use "Get-member" or "GM" - it will be a long list.
$getUsers | gm | more
$uPath | gm | more
## Here I'm saving the ADSI path of the user I selected for $uPath
$Users = [ADSI] $uPath.ADSIPath
## - I display the name property of $User
## return -> MaxRTrinidad
## - We change the name and add spaces
$User.name = "Max R Trinidad"
## - Save the changes we use the CommitChanges() method
$User.name #should reflect updated name.
## That's it using pure PowerShell...


Using Quest Quest.ActiveRoles.ADManagement Snapins, here’s the shorter way.  Wiith Quest AD Cmdlet, using the Set-QADuser to change AD Users properties:

## - This is just a very basic sample:
## - Using Quest Cmdlet Set-QADUser we just query for the User name.
$user = SET-QADUser MaxTrinidad
# - Display user title in AD
Result: Developer/Analyst
# - Here we are going to Change Title 
$user.title = "CIO"
# - Verify user title content has change
Result: CIO
# - Following step will commit the changes back to AD
## Go back and query AD to see the changes.


Quest provide you with the ability to code less.  As you can see, you can go different directions with PowerShell and there’s always a way  to complete a task.  Just don’t be afraid to try stuff in PowerShell because there’s always help available.

Happy PowerShelling!!




About maxt2posh

I’m from Puerto Rico, have been working with computers since 1979. Throughout many years, I have worked with SQL Server Technologies, provided support to Windows Servers/Client machines, Microsoft Virtualization Technologies, and build some Visual Studio solutions. I’m a Microsoft PowerShell MVP since 2009 and MVP SAPIEN Technologies since 2010. I speak in most of the SQLSaturday, IT Pro and .NET camps events around the Florida’s State. Also founder of the Florida PowerShell User Group which meeting every 3rd Tuesday evening of the month.
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s