Categories

Bulk group creation–Microsoft cmdlets

Last but not least the Microsoft cmdlet version – only change from the Quest cmdlet is the parameter names on the cmdlet

function new-securitygroup {            
[CmdletBinding()]            
param (            
 [parameter(ValueFromPipeline=$true,             
   ValueFromPipelineByPropertyName=$true)]            
 [string]$name,            
             
  [parameter(ValueFromPipeline=$true,             
   ValueFromPipelineByPropertyName=$true)]            
 [string]$description,            
             
  [parameter(ValueFromPipeline=$true,             
   ValueFromPipelineByPropertyName=$true)]            
 [string]$ou,            
             
 [parameter(ParameterSetName="U")]            
 [switch]$universal,            
             
 [parameter(ParameterSetName="G")]            
 [switch]$global,            
             
 [parameter(ParameterSetName="DL")]            
 [switch]$domainlocal            
)            
BEGIN {}            
PROCESS {            
            
switch ($psCmdlet.ParameterSetName) {            
 "DL" {$grouptype = "DomainLocal"}            
 "G"  {$grouptype = "Global" }            
 "U"  {$grouptype = "Universal" }            
 default {Write-Host "Error!!! Should not be here" }            
}            
            
New-ADGroup -Name $name -SamAccountName $name -Path $ou -Description $description `
-GroupScope $grouptype -GroupCategory Security            
            
} # end process block            
}

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>