Skip to content

PowerShell Shortcuts for AD

Danger

All the credentials below are given for exemplary purposes.

You can speed up user and group creation using PowerShell.

For advanced manipulations with AD users and groups, please refer to the official PowerShell documentation.

New User Group§

1
2
3
4
5
# set up name of the user group
$UserGroup = 'UserGroup01'

# create a new user group
New-ADGroup -Name $UserGroup -GroupScope Global

New User§

# set up username/login
$UserName = 'User01'

# set up user password
$UserPassword = 'user_password'

# create a new user
New-ADUser  -Name $UserName `
            -Password (ConvertTo-SecureString $UserPassword -AsPlainText -Force) `
            -Enabled = $true

The -Enabled parameter is required to activate the account. By default, it is created disabled.

Add User to User Group§

1
2
3
4
5
6
7
8
# set up username/login
$UserName = 'User01'

# set up name of the user group
$UserGroup = 'UserGroup01'

# add user to user group
Add-ADGroupMember  -Identity $UserGroup  -Members $UserName

See Also§