Skip to content

Commit e31e32a

Browse files
sandeepjha000Copilot
andcommitted
fix: wrap Where-Object pipelines in @() to prevent scalar collapse on single result
Co-authored-by: Copilot <copilot@github.com>
1 parent 32ec17e commit e31e32a

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

src/powershell/private/tests-shared/Get-ApplicationsWithInsufficientOwners.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ function Get-ApplicationsWithInsufficientOwners {
2222
$allApps = Get-ApplicationsWithPermissions -Database $Database -ExcludeServicePrincipalType 'ManagedIdentity'
2323

2424
# Filter by privilege level and owner count
25-
$filteredApps = $allApps | Where-Object {($PrivilegeLevel -contains $_.Risk) -and ($_.OwnerCount -lt 2)}
25+
$filteredApps = @($allApps | Where-Object {($PrivilegeLevel -contains $_.Risk) -and ($_.OwnerCount -lt 2)})
2626

2727
Write-PSFMessage "Filtered to $($filteredApps.Count) applications with < 2 owners matching privilege levels: $($PrivilegeLevel -join ', ')" -Level Verbose
2828

src/powershell/private/tests-shared/Get-ApplicationsWithPermissions.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ order by spsi.lastSignInActivity.lastSignInDateTime
5757

5858
# Exclude specified service principal types before enrichment to avoid unnecessary per-item DB calls
5959
if ($ExcludeServicePrincipalType) {
60-
$results = $results | Where-Object { $ExcludeServicePrincipalType -notcontains $_.servicePrincipalType }
60+
$results = @($results | Where-Object { $ExcludeServicePrincipalType -notcontains $_.servicePrincipalType })
6161
Write-PSFMessage "Excluded $($ExcludeServicePrincipalType -join ', ') type(s), $($results.Count) service principals remaining" -Level Verbose
6262
}
6363

0 commit comments

Comments
 (0)