Microsoft Powershell – Create AD Admin groups based on csv-file

Release date: December 21st 2022

Welcome to my Microsoft Tips & Tricks section. I recently experienced a complete hardware crash in my old lab, and had to do a complete rebuild. Although this was sad, it gave me the opportunity to do it by scripting this time. This involved recreating the security groups for my Admin users, as shown below.

To set up this, I first created a csv-file with “;” as the delimiter containing the following data:

  • name
  • path (Path to OU where Group will be created)
  • scope (DomainLocal/Global)
  • category (Security)
  • description

Next, using the script below, I easily recreated my Admin User Groups. NOTE: The user I ran this script with had Domain Admin permissions, otherwise this wouldn’t have worked.

Import-Module ActiveDirectory

$groups = Import-Csv "<Path to csv-file>.csv" -Delimiter ";"
    foreach ($group in $groups) {

    $groupProps = @{

      Name          = $group.name
      Path          = $group.path
      GroupScope    = $group.scope
      GroupCategory = $group.category
      Description   = $group.description
      }
    New-ADGroup @groupProps   
}

Now that I had created the Admin Users groups, I could now proceed with creating my Admin Users, which I also did by using a script, detailed here: Create AD Admin Users based on csv-file

Big thanks to: Robert Allen’s: Create Active Directory Security Groups with PowerShell

Microsoft Tips & Tricks section

Disclaimer: Every tips/tricks/posting I have published here, is tried and tested in different it-solutions. It is not guaranteed to work everywhere, but is meant as a tip for other users out there. Remember, Google is your friend and don’t be afraid to steal with pride! Feel free to comment below as needed.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: