From b68961cb95479348c93e17ea717622e54d6f512b Mon Sep 17 00:00:00 2001 From: Karl-Wilfried Zimmer Date: Sun, 14 Jul 2024 14:50:54 +0200 Subject: [PATCH] added check for project name being set --- AddProjectRoles.ps1 | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/AddProjectRoles.ps1 b/AddProjectRoles.ps1 index b5ed3f1..a193a2e 100644 --- a/AddProjectRoles.ps1 +++ b/AddProjectRoles.ps1 @@ -13,12 +13,16 @@ $Write = 'GR-'+$ProjectName+'-RW' $ret=@() -if($PSBoundParameters.ContainsKey("Server")){ - $ret += New-ADGroup -Path $Roles -Server $Server -Name $Read -GroupCategory Security -GroupScope Global - $ret += New-ADGroup -Path $Roles -Server $Server -Name $Write -GroupCategory Security -GroupScope Global -} else { - $ret += New-ADGroup -Path $Roles -Name $Read -GroupCategory Security -GroupScope Global - $ret += New-ADGroup -Path $Roles -Name $Write -GroupCategory Security -GroupScope Global +if($PSBoundParameters.ContainsKey("ProjectName")){ + if($PSBoundParameters.ContainsKey("Server")){ + $ret += New-ADGroup -Path $Roles -Server $Server -Name $Read -GroupCategory Security -GroupScope Global + $ret += New-ADGroup -Path $Roles -Server $Server -Name $Write -GroupCategory Security -GroupScope Global + } else { + $ret += New-ADGroup -Path $Roles -Name $Read -GroupCategory Security -GroupScope Global + $ret += New-ADGroup -Path $Roles -Name $Write -GroupCategory Security -GroupScope Global + } + + return $ret } -return $ret \ No newline at end of file +throw "ProjectName parameter needs to be set" \ No newline at end of file