From b1e447d652bb315fa80ce551d913d1ec1f8392a7 Mon Sep 17 00:00:00 2001 From: Karl-Wilfried Zimmer Date: Sun, 14 Jul 2024 13:01:03 +0200 Subject: [PATCH] added project group and role getter --- GetProjectUsers.ps1 | 6 ++++-- GetProjects.ps1 | 12 ++++++++++++ GetRoles.ps1 | 15 +++++++++++++-- 3 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 GetProjects.ps1 diff --git a/GetProjectUsers.ps1 b/GetProjectUsers.ps1 index ac874ca..f56e8ac 100644 --- a/GetProjectUsers.ps1 +++ b/GetProjectUsers.ps1 @@ -7,10 +7,12 @@ param ( if($PSBoundParameters.ContainsKey('Name')){ . .\Variables.ps1 - $Read='GR-'+$Name+'-RO,' - $Write='GR-'+$Name+'-RW,' + $Read='GR-'+$Name+'-RO' + $Write='GR-'+$Name+'-RW' Write-Host $Read+$Roles Write-Host $Write+$Roles + $ReadUsers=Get-ADGroupMember -Recursive -Identity $Read + $WriteUsers Return $null } diff --git a/GetProjects.ps1 b/GetProjects.ps1 new file mode 100644 index 0000000..14f6c84 --- /dev/null +++ b/GetProjects.ps1 @@ -0,0 +1,12 @@ +[CmdletBinding()] +param ( + [string] + $Server +) + +. .\Variables.ps1 +if($PSBoundParameters.ContainsKey("Server")){ + Get-ADGroups -Server $Server -SearchBase $Projects +} else { + Get-ADGroups -SearchBase $Projects +} \ No newline at end of file diff --git a/GetRoles.ps1 b/GetRoles.ps1 index 5e9fdae..e2d2df1 100644 --- a/GetRoles.ps1 +++ b/GetRoles.ps1 @@ -1,3 +1,14 @@ -. .\Variables.ps1 +[CmdletBinding()] +param ( + [string] + $Server, +) -Get-ADGroup -SearchBase $Roles \ No newline at end of file +$Projects +if($PSBoundParameters.ContainsKey("Server")){ + $Projects = . .\GetProjects.ps1 -Server $Server +} else { + $Projects = . .\GetProjects.ps1 +} + +$Projects | Get-ADGroupMember | Where-Object Name -Match "GR.*" \ No newline at end of file