From 81dba8289b1c230d3e6e9c1cc80ae9cbb2e53062 Mon Sep 17 00:00:00 2001 From: Karl-Wilfried Zimmer Date: Sun, 14 Jul 2024 14:45:53 +0200 Subject: [PATCH] added check for project name being set --- NewProject.ps1 | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/NewProject.ps1 b/NewProject.ps1 index 601273d..babc31f 100644 --- a/NewProject.ps1 +++ b/NewProject.ps1 @@ -12,22 +12,26 @@ $ret $acl $r -if($PSBoundParameters.ContainsKey("Server")){ - $ret = New-ADGroup -Path $Projects -Server $Server -Name $ProjectName -GroupCategory Security -GroupScope Global - $acl = . .\AddProjectACL.ps1 -ProjectName $ProjectName -Server $Server - $r = . .\AddProjectRoles.ps1 -ProjectName $ProjectName -Server $Server - #$ret | Add-ADGroupMember -Members $acl,$r - $acl | ForEach-Object {New-ADGroupMember -Identity $ret -Member $_ -Server $Server} - $r | ForEach-Object {New-ADGroupMember -Identity $ret -Member $_ -Server $Server} -} else { +if($PSBoundParameters.ContainsKey($ProjectName)){ + if($PSBoundParameters.ContainsKey("Server")){ + $ret = New-ADGroup -Path $Projects -Server $Server -Name $ProjectName -GroupCategory Security -GroupScope Global + $acl = . .\AddProjectACL.ps1 -ProjectName $ProjectName -Server $Server + $r = . .\AddProjectRoles.ps1 -ProjectName $ProjectName -Server $Server + #$ret | Add-ADGroupMember -Members $acl,$r + $acl | ForEach-Object {New-ADGroupMember -Identity $ret -Member $_ -Server $Server} + $r | ForEach-Object {New-ADGroupMember -Identity $ret -Member $_ -Server $Server} + } else { - $ret = New-ADGroup -Path $Projects -Name $ProjectName -GroupCategory Security -GroupScope Global - $acl = . .\AddProjectACL.ps1 -ProjectName $ProjectName - $r = . .\AddProjectRoles.ps1 -ProjectName $ProjectName - #$ret | Add-ADGroupMember -Members $acl,$r - $acl | ForEach-Object {New-ADGroupMember -Identity $ret -Member $_} - $r | ForEach-Object {New-ADGroupMember -Identity $ret -Member $_} + $ret = New-ADGroup -Path $Projects -Name $ProjectName -GroupCategory Security -GroupScope Global + $acl = . .\AddProjectACL.ps1 -ProjectName $ProjectName + $r = . .\AddProjectRoles.ps1 -ProjectName $ProjectName + #$ret | Add-ADGroupMember -Members $acl,$r + $acl | ForEach-Object {New-ADGroupMember -Identity $ret -Member $_} + $r | ForEach-Object {New-ADGroupMember -Identity $ret -Member $_} + } + + return $ret } -return $ret +throw "ProjectName parameter needs to be set"