Scroll To Top

How to Create User Account Using PowerShell?

Posted in Articles, MCSA, Servers8 months ago • Written by Shais3 Comments

How to create User Account using PowerShell in Active Directory. I’m using Windows Server 2012 R2, but this article will work with Windows Server 2008 to Server 2012 R2 or Server 2016.

A simple description about PowerShell. Windows PowerShell is a task automation and configuration management framework from Microsoft, consisting of a command-line shell and associated scripting language built on the .NET Framework. PowerShell provides full access to COM and WMI, enabling administrators to perform administrative tasks on both local and remote Windows systems as well as WS-Management and CIM enabling management of remote Linux systems and network devices.

So if you have problem with creating objects in Active Directory with GUI, read the article: How to Create Objects in Active Directory?

Create User Account using PowerShell

In Windows Server run PowerShell and import Active Directory module or run Active directory module for Windows PowerShell from Tools in Server manager dashboard.

Active Directory Module for Windows PowerShell

Active Directory Module for Windows PowerShell

Type ‘Import-Module activedirectory’ and press enter to import the AD PowerShell module. This action will load all Active Directory commands for using in the current PowerShell window.

Import Active Directory module

Import Active Directory module

If you close the current PowerShell window, the Active Directory module will also exit and unload from PowerShell.

Type Get-Module and press enter to insure that module loaded successfully.

Create User Account

Loaded modules

To see and list all active directory commands (CmdLet), just type ‘Get-Command -Module activedirectory’ and press enter then once explore all commands.

Active Directory PowerShell Commands

Active Directory PowerShell Commands

We need to create User Account with New-ADUser command. Type the below command and press enter.

PS C:\> New-ADUser -Name “Mehdi Hussaini” -GivenName Mehdi -Surname Hussaini -SamAccountName Mehdi -UserPrincipalName Mehdi@technig.local -AccountPassword (ConvertTo-SecureString -AsPlainText “PassW0rD” -Force ) -Enabled $true -ChangePasswordAtLogon $true

New-ADUser Command

New-ADUser Command

To get help for a command type ‘Get-Help New-ADUser -full’ or –example.  The –full option will show you by details but the –example just show some examples for command.

To see if the user (Hehdi) has created or not, simply type ‘Get-ADUser -Identity Mehdi’ and press enter.

Get-ADUser Command

Get-ADUser Command

For getting full information about a user, type ‘Get-ADUser -Identity -Properties *’ then press enter.

That’s all, simple and easy. But it’s better to know the below Active Directory CmdLets for managing user account also.

1. To enable an Account type: ‘Enable-ADAccount -Identity mehdi’. This will enable the disabled user account immediately.

2. Disable an Account: ‘Disable-ADAccount -Identity Mehdi’

Disable User Account with PowerShell

Disable User Account with PowerShell

3. Reset the password of an account.

PS C:\> Set-ADAccountPassword -Identity mehdi -Reset
Please enter the desired password for ‘CN=Mehdi Hussaini,CN=Users,DC=Technig,DC=local’
Password: ********
Repeat Password: ********
PS C:\>

Modify User Account with PowerShell

Modify User Account with PowerShell

4. Remove a User Account: ‘Remove-ADUser -Identity Mehdi’

Delete User Account with PowerShell

Delete User Account with PowerShell

OK. Now you can create, modify, enable, disable, and delete a user account from active directory with Windows PowerShell within Windows Servers. Hope you enjoy to create user account using PowerShell


TAGS: , , , , ,
About this Author
Shais

I'm a network and Information Security instructor. Here is my online pictorial notebook. I would like to write and share my experience through this website for computer enthusiasts and technology geeks.

Like us on Facebook
on Facebook
Shais

Follow me on Twitter
Follow @technigs on Twitter
Shais
Add me on Google+
on Google+
Shais

3 Comments so far. Feel free to join this conversation.

  1. FarazDecember 25, 2014 at 9:08 am - Reply

    Hi dear sir can u teach me how to unlock youtube in good way which we can download high qualities video when we visit youtube from zacebook.com sometimes it cant work and when it works we cant download high quality videos

    • Shais
      ShaisDecember 25, 2014 at 2:01 pm - Reply

      Hi Faraz, the free proxy services just let you watch YouTube online and blocked the downloading.
      Use http://www.clipconverter.cc to convert and download the links or buy a premium VPN Apps.

  2. IsmAil FarHangJune 5, 2016 at 11:48 am - Reply

    this article becomes all too skillful if he or she are able to learn it, it was so great and super.

Leave A Response