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: , , , ,

4 Responses to “Enable User Accounts with PowerShell”


  1. 1 Ms.Pat July 21, 2007 at 7:35 pm

    when i open the control panel & click on user accounts a blank page comes up. How do i get into user accounts??

  2. 2 dmitrysotnikov July 21, 2007 at 8:03 pm

    It looks like we are actually talking about different types of accounts. I am primarily writing about Active Directory management - so these are the accounts which administrators set up in enterprise networks.

    It looks like you are asking about local accounts on a Windows XP (or Vista) computer. While I am not a specialist at troubleshooting such issues one of the possible reasons might be your lack of administrative privileges on the computer. Try logging in as an administrator and see if you can now see all accounts (it might take a few seconds before the list gets populated.)

  3. 3 Ms.Pat July 22, 2007 at 6:10 pm

    Thank you but in order to login in as an administrator i have to get into the user account in the control panel which i cannot do. The screen comes up blank but on top it says “screen name server” & i don’t have a clue what that means.

  4. 4 dmitrysotnikov July 23, 2007 at 11:15 am

    I found a few posts on the internet mentioning the same problem but none seems to suggest a good workaround so you might have to roll-back to a previously saved system state or even reinstall Windows if none of these help (and you can’t use Microsoft’s tech support):

    http://windowsxp.mvps.org/useracc.htm

    http://forums.techguy.org/windows-nt-2000-xp/586157-user-accounts-folder-empty.html

Leave a Reply




View Dmitry Sotnikov's profile on LinkedIn

Archives

See you at:

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 Quest Software or anyone else for that matter. All trademarks acknowledged.

© 2007 Dmitry Sotnikov