Creating groups in bulk
Previously, we have seen bulk creation of users using PowerShell. A similar requirement might come from creating security groups in bulk. The function given in the following code helps in creating groups in a bulk fashion. It creates a security group of a given scope (domain local, global, or universal) inside the default user's container by default. They can be created in different locations in the Active Directory structure by updating the $TargetOU
variable's value with the DN of the OU where you want to create them:
Function Invoke-ADBulkGroup { [CmdletBinding()] Param( [Parameter(Mandatory=$true, Position = 0)] [String[]]$GroupName, [Parameter(Mandatory=$true, Position = 1)] [ValidateSet("DomainLocal","Global","Universal")] [string]$GroupScope ) #Change the value of $TargetOU variable to the DN of the path where you want the groups to be created #If you leave it, it will create in default users container. $TargetOU = (Get-ADDomain).UsersContainer #...