From 67b822938e79c1fb4c4f4cdf0f0256322c511a71 Mon Sep 17 00:00:00 2001 From: Karl-Wilfried Zimmer Date: Mon, 15 Jul 2024 21:36:39 +0200 Subject: [PATCH] added mitigation for accidentally getting a list or array --- GetACLs.ps1 | 3 +++ GetRoles.ps1 | 20 +++++++++++++++----- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/GetACLs.ps1 b/GetACLs.ps1 index 25aad83..77eedd7 100644 --- a/GetACLs.ps1 +++ b/GetACLs.ps1 @@ -15,6 +15,9 @@ if($PSBoundParameters.ContainsKey("Server")){ if($PSBoundParameters.ContainsKey("ProjectName")){ $Projects = $Projects | Where-Object Name -Match $ProjectName + if($ProjectName.Count -ge 1){ + $Projects=$Projects[0] + } } return $Projects | Get-ADGroupMember | Where-Object Name -Match "ACL.*" \ No newline at end of file diff --git a/GetRoles.ps1 b/GetRoles.ps1 index 6c8bb2f..972611b 100644 --- a/GetRoles.ps1 +++ b/GetRoles.ps1 @@ -7,14 +7,24 @@ param ( ) $Projects=$null -if($PSBoundParameters.ContainsKey("Server")){ - $Projects = . .\GetProjects.ps1 -Server $Server -} else { - $Projects = . .\GetProjects.ps1 +if($PSBoundParameters.ContainsKey("ProjectName")){ + if($PSBoundParameters.ContainsKey("Server")){ + $Projects = . .\GetProjects.ps1 -Server $Server + } else { + $Projects = . .\GetProjects.ps1 + } +} else{ + if($PSBoundParameters.ContainsKey("Server")){ + $Projects = . .\GetProjects.ps1 -Server $Server + } else { + $Projects = . .\GetProjects.ps1 + } } - if($PSBoundParameters.ContainsKey("ProjectName")){ $Projects = $Projects | Where-Object Name -Match $ProjectName + if($ProjectName.Count -ge 1){ + $Projects=$Projects[0] + } } return $Projects | Get-ADGroupMember | Where-Object Name -Match "GR.*" \ No newline at end of file