PowerShell as an AD group management tool

PowerShell as an AD group management tool

Group management can be quite a challenge for Active Directory (AD) administrators day in, day out. Many administrators use Microsoft's PowerShell technology to perform basic AD user management tasks. Below are some key PowerShell scripts and commands for working with AD groups.

Creating a group

New-ADGroup -Name test -GroupScope 1 -GroupCategory 1

Adding users to a group

Add-ADGroupMember -Identity "DomainGuest" -Members testUser

Setting group membership

Add-ADGroupMember -Identity "DomainGuest" -Members testUser

Modifying group membership

Remove-ADGroupMember -Identity "DomainGuest1" -Members testUser Add-ADGroupMember -Identity "DomainGuest2" -Members testUser

Creating groups in bulk

Import-CsvC:\Users\administrator.AUTOMATION\Desktop\Sample.csv | foreach {New-ADGroup-Name $_.sAMAccountName -GroupScope$_.GroupScope -GroupCategory $_.GroupCategory}

Creating security groups in bulk

Import-CsvC:\Users\administrator.AUTOMATION\Desktop\Sample.csv | foreach {New-ADGroup-Name $_.sAMAccountName -GroupScope$_.GroupScope -GroupCategory $_.1}


    • Related Articles

    • PowerShell as an AD user management tool

      User management can be quite a challenge for Active Directory (AD) administrators day in and day out. Many administrators use Microsoft's PowerShell technology to perform basic AD user management tasks. Below are some key PowerShell scripts and ...
    • PowerShell as an AD bulk user management tool

      Bulk AD user creation can be quite a challenge for Active Directory (AD) administrators day in, day out. Many administrators use Microsoft's PowerShell to create users and perform other such basic AD user management tasks. Below are some key ...
    • Generate an Activity Report for Microsoft 365 Groups and Teams

      Introduction The activity reports available for Microsoft 365 groups and Teams can be beneficial for administrators in an organization. Microsoft 365 teams group activity reports provide insight into group activities, group workloads, group counts, ...
    • How to find unused Exchange Online mailboxes

      What are unused Exchange Online mailboxes and how to identify them? Unused Exchange Online mailboxes are user mailboxes which are currently not being used by their users. There are 3 ways in which we can identify if a mailbox is unused or not. They ...
    • PowerShell for AD group reports

      Real-time insights on group membership, type, and scope can help Active Directory (AD) administrators manage group objects better. Many administrators use Microsoft's PowerShell technology to run basic queries and pull detailed information. Below are ...