added mitigation for accidentally getting a list or array

This commit is contained in:
Karl-Wilfried Zimmer 2024-07-15 21:36:39 +02:00
parent 2248f91d25
commit 67b822938e
2 changed files with 18 additions and 5 deletions

View File

@ -15,6 +15,9 @@ if($PSBoundParameters.ContainsKey("Server")){
if($PSBoundParameters.ContainsKey("ProjectName")){ if($PSBoundParameters.ContainsKey("ProjectName")){
$Projects = $Projects | Where-Object Name -Match $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.*" return $Projects | Get-ADGroupMember | Where-Object Name -Match "ACL.*"

View File

@ -7,14 +7,24 @@ param (
) )
$Projects=$null $Projects=$null
if($PSBoundParameters.ContainsKey("ProjectName")){
if($PSBoundParameters.ContainsKey("Server")){ if($PSBoundParameters.ContainsKey("Server")){
$Projects = . .\GetProjects.ps1 -Server $Server $Projects = . .\GetProjects.ps1 -Server $Server
} else { } else {
$Projects = . .\GetProjects.ps1 $Projects = . .\GetProjects.ps1
} }
} else{
if($PSBoundParameters.ContainsKey("Server")){
$Projects = . .\GetProjects.ps1 -Server $Server
} else {
$Projects = . .\GetProjects.ps1
}
}
if($PSBoundParameters.ContainsKey("ProjectName")){ if($PSBoundParameters.ContainsKey("ProjectName")){
$Projects = $Projects | Where-Object Name -Match $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.*" return $Projects | Get-ADGroupMember | Where-Object Name -Match "GR.*"