From a8f94c7d7807ae9d50b027af7cad46bd88989e2e Mon Sep 17 00:00:00 2001 From: Karl-Wilfried Zimmer Date: Sun, 14 Jul 2024 16:27:01 +0200 Subject: [PATCH] linking groups implemented --- AddProjectACL.ps1 | 8 ++++---- AddProjectRoles.ps1 | 8 ++++---- NewProject.ps1 | 14 ++++++++------ 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/AddProjectACL.ps1 b/AddProjectACL.ps1 index 8526ee2..628cdbf 100644 --- a/AddProjectACL.ps1 +++ b/AddProjectACL.ps1 @@ -15,11 +15,11 @@ $ret=@() if($PSBoundParameters.ContainsKey("ProjectName")){ if($PSBoundParameters.ContainsKey("Server")){ - $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 + $ret += New-ADGroup -Path $ACL -Server $Server -Name $Read -GroupCategory Security -GroupScope Global -PassThru + $ret += New-ADGroup -Path $ACL -Server $Server -Name $Write -GroupCategory Security -GroupScope Global -PassThru } else { - $ret += New-ADGroup -Path $ACL -Name $Read -GroupCategory Security -GroupScope Global - $ret += New-ADGroup -Path $ACL -Name $Write -GroupCategory Security -GroupScope Global + $ret += New-ADGroup -Path $ACL -Name $Read -GroupCategory Security -GroupScope Global -PassThru + $ret += New-ADGroup -Path $ACL -Name $Write -GroupCategory Security -GroupScope Global -PassThru } return $ret } diff --git a/AddProjectRoles.ps1 b/AddProjectRoles.ps1 index a193a2e..6dc7a08 100644 --- a/AddProjectRoles.ps1 +++ b/AddProjectRoles.ps1 @@ -15,11 +15,11 @@ $ret=@() 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 + $ret += New-ADGroup -Path $Roles -Server $Server -Name $Read -GroupCategory Security -GroupScope Global -PassThru + $ret += New-ADGroup -Path $Roles -Server $Server -Name $Write -GroupCategory Security -GroupScope Global -PassThru } else { - $ret += New-ADGroup -Path $Roles -Name $Read -GroupCategory Security -GroupScope Global - $ret += New-ADGroup -Path $Roles -Name $Write -GroupCategory Security -GroupScope Global + $ret += New-ADGroup -Path $Roles -Name $Read -GroupCategory Security -GroupScope Global -PassThru + $ret += New-ADGroup -Path $Roles -Name $Write -GroupCategory Security -GroupScope Global -PassThru } return $ret diff --git a/NewProject.ps1 b/NewProject.ps1 index d5c6cf0..ffa50a7 100644 --- a/NewProject.ps1 +++ b/NewProject.ps1 @@ -14,19 +14,21 @@ $r 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 -PassThru + $ret = Get-ADGroup $ProjectName -SearchBase $Projects -Server $Server $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} + $acl | ForEach-Object {add-ADGroupMember -Identity "$ret.DistinguishedName" -Members $_ -Server $Server} + $r | ForEach-Object {Add-ADGroupMember -Identity "$ret.DistinguishedName" -Members $_ -Server $Server} } else { - $ret = New-ADGroup -Path $Projects -Name $ProjectName -GroupCategory Security -GroupScope Global + $ret = New-ADGroup -Path $Projects -Name $ProjectName -GroupCategory Security -GroupScope Global -PassThru + $ret = Get-ADGroup $ProjectName -SearchBase $Projects $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 $_} + $acl | ForEach-Object {Add-ADGroupMember -Identity "$ret.DistinguishedName" -Members $_} + $r | ForEach-Object {Add-ADGroupMember -Identity "$ret.DistinguishedName" -Members $_} } return $ret