added check for project name being set

This commit is contained in:
Karl-Wilfried Zimmer 2024-07-14 14:45:53 +02:00
parent 3dfa7a0e58
commit 81dba8289b

View File

@ -12,14 +12,15 @@ $ret
$acl $acl
$r $r
if($PSBoundParameters.ContainsKey("Server")){ if($PSBoundParameters.ContainsKey($ProjectName)){
if($PSBoundParameters.ContainsKey("Server")){
$ret = New-ADGroup -Path $Projects -Server $Server -Name $ProjectName -GroupCategory Security -GroupScope Global $ret = New-ADGroup -Path $Projects -Server $Server -Name $ProjectName -GroupCategory Security -GroupScope Global
$acl = . .\AddProjectACL.ps1 -ProjectName $ProjectName -Server $Server $acl = . .\AddProjectACL.ps1 -ProjectName $ProjectName -Server $Server
$r = . .\AddProjectRoles.ps1 -ProjectName $ProjectName -Server $Server $r = . .\AddProjectRoles.ps1 -ProjectName $ProjectName -Server $Server
#$ret | Add-ADGroupMember -Members $acl,$r #$ret | Add-ADGroupMember -Members $acl,$r
$acl | ForEach-Object {New-ADGroupMember -Identity $ret -Member $_ -Server $Server} $acl | ForEach-Object {New-ADGroupMember -Identity $ret -Member $_ -Server $Server}
$r | ForEach-Object {New-ADGroupMember -Identity $ret -Member $_ -Server $Server} $r | ForEach-Object {New-ADGroupMember -Identity $ret -Member $_ -Server $Server}
} else { } else {
$ret = New-ADGroup -Path $Projects -Name $ProjectName -GroupCategory Security -GroupScope Global $ret = New-ADGroup -Path $Projects -Name $ProjectName -GroupCategory Security -GroupScope Global
$acl = . .\AddProjectACL.ps1 -ProjectName $ProjectName $acl = . .\AddProjectACL.ps1 -ProjectName $ProjectName
@ -27,7 +28,10 @@ if($PSBoundParameters.ContainsKey("Server")){
#$ret | Add-ADGroupMember -Members $acl,$r #$ret | Add-ADGroupMember -Members $acl,$r
$acl | ForEach-Object {New-ADGroupMember -Identity $ret -Member $_} $acl | ForEach-Object {New-ADGroupMember -Identity $ret -Member $_}
$r | 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"