Related to creating objects in AD, learn how to create and manage Group Accounts in Active Directory within Windows Servers. You can perform the tasks on all Windows Servers from 2008 to 2012 R2. Using PowerShell to manage Active Directory is not hard, if you try to understand the PowerShell CmdLets structures.
Manage Group Accounts in Active Directory Using PowerShell
The easy way to learn PowerShell is to perform some simple network management tasks with PowerShell. Specially when you are working with Active directory, Exchange Server, and other Microsoft products.
Create and Mange Group Accounts in Active Directory
In Windows Server run PowerShell and load active directory module. Type ‘Import-Module activedirectory’ and press enter.
![Active Directory Module for Windows PowerShell](https://www.technig.com/wp-content/uploads/2014/12/Active-Directory-Module-for-Windows-PowerShell1.jpg)
To see the result, type ‘Get-Module’ and press enter.
Find the related PowerShell CmdLets for group account, type ‘Get-Command *ADGroup*’ and press enter.
![Manage group accounts in active directory](https://www.technig.com/wp-content/uploads/2014/12/PowerShell-Group-Account-CmdLets.jpg)
Create a group with ‘New-ADGroup’
PS C:\> New-ADGroup -Name “Sales Team” -DisplayName “Sales Members” -SamAccountName SalesTeam -GroupScope global -GroupCategory Security -Description “Technig Products Sales Team”
![Create a Group with PowerShell](https://www.technig.com/wp-content/uploads/2014/12/Create-a-Group-with-PowerShell.jpg)
To see the group account attributes or Properties type ‘Get-ADGroup -Identity salesteam -Properties *’ and press enter.
![Group Account Attributes](https://www.technig.com/wp-content/uploads/2014/12/Group-Account-Attributes.jpg)
You can add users to a Group with ‘Add-ADGroupMember -Identity Salesteam -Members Nigar,Mahdi’ command.
![Add Users to Group with PowerShell Command](https://www.technig.com/wp-content/uploads/2014/12/Add-Users-to-Group-with-PowerShell-Command.jpg)
Now I have added users Nigar and Mahdi to SalesTeam group.
![Show Group Members with Command](https://www.technig.com/wp-content/uploads/2014/12/Show-Group-Members-with-Command.jpg)
The ‘Get-ADGroupMember salesteam’ will show you all members of SalesTeam group.
Remove a user from group, type ‘Remove-ADGroupMember -Identity SalesTeam -Members Mahdi’ and press enter. When ask you Are you sure you want to perform this action? Just type Y then press enter to accept it.
![Remove an Account from a Group with Command](https://www.technig.com/wp-content/uploads/2014/12/Remove-an-Account-from-a-Group-with-Command.jpg)
Do the same to remove a group with Remove-ADGroup command. If you want to modify a group attributes, do it with Set-ADGroup command.
OK friends that’s all about How to Create and Manage group accounts in active directory. You may need to read How to create User Account with PowerShell in Active Directory or you have any question? just ask trough comment.