Archive for April 28th, 2007

Enable User Accounts with PowerShell

Question: How to enable AD user account using Windows PowerShell cmdlets?

Answer (shamelessly stolen from Andrei’s post in the PowerGUI discussion forum):

1. [If this is a new account] Create the account using New-QADUser. Make sure the password is also set (-UserPassword parameter)

2. Enable the account by setting userAccountControl to 512: e.g.

Set-QADUser TEST\testuser -ObjectAttributes @{userAccountControl=512}

Bulk account provisioning: 

If you want to do that in bulk using csv file for bulk user account provisioning this might (depending on the columns in your file and attributes being set) look like:

PS C:\> Import-Csv users.csv | ForEach-Object {New-QADUser -ou acme.local/demo -name $_.Name -UserPassword $_.Password

PS C:\> Import-Csv users.csv | ForEach-Object {Set-QADUser $_.Name -ObjectAttributes @{userAccountControl=512}}

Due to AD cmdlets not having a community site of their own we have created a forum for Active Directory PowerShell discussions on PowerGUI.org. Andrei and other members of his team are there for your questions, feature requests, etc.

Tags: , , , ,

Advertisement

Legal

The posts on this blog are provided “as is” with no warranties and confer no rights. The opinions expressed on this site are mine and mine alone, and do not necessarily represent those of my employer - WSO2 or anyone else for that matter. All trademarks acknowledged.

© 2007-2014 Dmitry Sotnikov

April 2007
M T W T F S S
 1
2345678
9101112131415
16171819202122
23242526272829
30  

%d bloggers like this: