From 73b9838b5b588da91688c6c6c4940dcead9ad6cd Mon Sep 17 00:00:00 2001 From: Karl-Wilfried Zimmer Date: Sun, 14 Jul 2024 14:26:26 +0200 Subject: [PATCH] now links created groups to project group --- AddProjectACL.ps1 | 12 ++++++++---- AddProjectRoles.ps1 | 14 +++++++++----- NewProject.ps1 | 23 ++++++++++++++++------- 3 files changed, 33 insertions(+), 16 deletions(-) diff --git a/AddProjectACL.ps1 b/AddProjectACL.ps1 index 0eb68f6..85d276c 100644 --- a/AddProjectACL.ps1 +++ b/AddProjectACL.ps1 @@ -11,10 +11,14 @@ param ( $Read = 'ACL-'+$ProjectName+'-RO' $Write = 'ACL-'+$ProjectName+'-RW' +$ret=@() + if($PSBoundParameters.ContainsKey("Server")){ - New-ADGroup -Path $ACL -Server $Server -Name $Read -GroupCategory Security -GroupScope Global - New-ADGroup -Path $ACL -Server $Server -Name $Write -GroupCategory Security -GroupScope Global + $ret += New-ADGroup -Path $ACL -Server $Server -Name $Read -GroupCategory Security -GroupScope Global + $ret += New-ADGroup -Path $ACL -Server $Server -Name $Write -GroupCategory Security -GroupScope Global } else { - New-ADGroup -Path $ACL -Name $Read -GroupCategory Security -GroupScope Global - New-ADGroup -Path $ACL -Name $Write -GroupCategory Security -GroupScope Global + $ret += New-ADGroup -Path $ACL -Name $Read -GroupCategory Security -GroupScope Global + $ret += New-ADGroup -Path $ACL -Name $Write -GroupCategory Security -GroupScope Global } + +return $ret \ No newline at end of file diff --git a/AddProjectRoles.ps1 b/AddProjectRoles.ps1 index db6b457..b5ed3f1 100644 --- a/AddProjectRoles.ps1 +++ b/AddProjectRoles.ps1 @@ -11,10 +11,14 @@ param ( $Read = 'GR-'+$ProjectName+'-RO' $Write = 'GR-'+$ProjectName+'-RW' +$ret=@() + if($PSBoundParameters.ContainsKey("Server")){ - New-ADGroup -Path $Roles -Server $Server -Name $Read -GroupCategory Security -GroupScope Global - New-ADGroup -Path $Roles -Server $Server -Name $Write -GroupCategory Security -GroupScope Global + $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 { - New-ADGroup -Path $Roles -Name $Read -GroupCategory Security -GroupScope Global - New-ADGroup -Path $Roles -Name $Write -GroupCategory Security -GroupScope Global -} \ No newline at end of file + $ret += New-ADGroup -Path $Roles -Name $Read -GroupCategory Security -GroupScope Global + $ret += New-ADGroup -Path $Roles -Name $Write -GroupCategory Security -GroupScope Global +} + +return $ret \ No newline at end of file diff --git a/NewProject.ps1 b/NewProject.ps1 index 58b0ab0..59c103b 100644 --- a/NewProject.ps1 +++ b/NewProject.ps1 @@ -8,13 +8,22 @@ param ( . .\Variables.ps1 +$ret +$acl +$r + if($PSBoundParameters.ContainsKey("Server")){ - New-ADGroup -Path $Projects -Server $Server -Name $ProjectName -GroupCategory Security -GroupScope Global - . .\AddProjectACL.ps1 -ProjectName $ProjectName -Server $Server - . .\AddProjectRoles.ps1 -ProjectName $ProjectName -Server $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 } else { - New-ADGroup -Path $Projects -Name $ProjectName -GroupCategory Security -GroupScope Global - . .\AddProjectACL.ps1 -ProjectName $ProjectName - . .\AddProjectRoles.ps1 -ProjectName $ProjectName -} \ No newline at end of file + $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 +} + +return $ret +