Bulk group creation–Quest cmdlets

Using cmdlets the function is simplified even further

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-QADGroup  -Name $name -SamAccountName $name -ParentContainer $ou -Description $description `
-GroupScope $grouptype -GroupType "Security"            
            
} # end process block            
}

Leave a Reply