Simple AD Group Management

by Jul 13, 2015

Provided you have downloaded and installed Microsoft’s free RSAT tools, managing AD groups and group members is very simple. Here are some lines of code that can serve as examples on how to get started:

#requires -Version 1 -Modules ActiveDirectory
# create new AD group
New-ADGroup -DisplayName PowerShellGurus -GroupScope DomainLocal -Name PSGurus 

# get group 
Get-ADGroup -Identity PSGurus -Credential $cred -Server

# select users by some criteria
$newMembers = Get-ADUser -Filter 'Name -like "User*"' 

# add them to new AD group
Add-ADGroupMember -Identity 'PSGurus' -Members $newMembers 

# list members of group
Get-ADGroupMember -Identity PSGurus 

Twitter This Tip! ReTweet this Tip!