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: AD cmdlets, provisioning, PowerShell, Active Directory, AD