Site icon Kommands.com

Managing Domain User Accounts and Groups using PowerShell and the Command Prompt

Creating a domain user account and adding it to the Domain Admins group is a common task that is often performed by network administrators. In this blog, we will show you how to do this using PowerShell and the Command Prompt in Windows.

To create a domain user account and add it to the Domain Admins group using PowerShell, follow these steps:

  1. Open PowerShell as an administrator by right-clicking on the PowerShell icon and selecting “Run as administrator”.
  2. Connect to your domain by running the following command:
Import-Module ActiveDirectory
  1. Create the domain user account by running the following command:
New-ADUser -Name "UserName" -GivenName "FirstName" -Surname "LastName" -SamAccountName "username" -UserPrincipalName "username@domain.com" -AccountPassword (Read-Host -AsSecureString "Enter Password") -Enabled $true

Replace “UserName”, “FirstName”, “LastName”, “username”, and “username@domain.com” with the desired values for the user’s name, username, and email address.

  1. Add the user to the Domain Admins group by running the following command:
Add-ADGroupMember -Identity "Domain Admins" -Members "username"

Replace “username” with the username of the user you just created.

That’s it! The domain user account should now be created and added to the Domain Admins group. You can verify this by checking the list of members in the Domain Admins group using the following command:

Get-ADGroupMember -Identity "Domain Admins"

To create a domain user account and add it to the Domain Admins group using the Command Prompt, follow these steps:

  1. Open the Command Prompt by typing “cmd” in the search bar and pressing Enter.
  2. Create the domain user account by running the following command:
net user username password /add /domain

Replace “username” and “password” with the desired values for the username and password of the user account.

  1. Add the user to the Domain Admins group by running the following command:
net localgroup "Domain Admins" username /add /domain

Replace “username” with the username of the user you just created.

That’s it! The domain user account should now be created and added to the Domain Admins group. You can verify this by running the following command:

net localgroup "Domain Admins"
Exit mobile version