From 34abeabcd077d7a0138bc8ed76d9cb2440546a69 Mon Sep 17 00:00:00 2001 From: Marco Valle Date: Mon, 30 Mar 2026 14:50:17 +0200 Subject: [PATCH] fix: Get-IntuneWin32AppSupersedence scalar logic * Replaced .Count check with $null check for $Win32AppRelationsResponse to support scalar responses in Windows PowerShell. * Applied @() subexpression to normalize $SupersedenceRelationships as an array, ensuring a valid .Count property. * Updated Write-Verbose to utilize the guaranteed count of the normalized array. --- Public/Get-IntuneWin32AppSupersedence.ps1 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Public/Get-IntuneWin32AppSupersedence.ps1 b/Public/Get-IntuneWin32AppSupersedence.ps1 index cf92638..be0477d 100644 --- a/Public/Get-IntuneWin32AppSupersedence.ps1 +++ b/Public/Get-IntuneWin32AppSupersedence.ps1 @@ -47,11 +47,11 @@ function Get-IntuneWin32AppSupersedence { $Win32AppRelationsResponse = Invoke-MSGraphOperation -Get -APIVersion "Beta" -Resource "deviceAppManagement/mobileApps/$($Win32AppID)/relationships" -ErrorAction Stop # Handle return value - if ($null -ne $Win32AppRelationsResponse -and $Win32AppRelationsResponse.Count -gt 0) { + if ($null -ne $Win32AppRelationsResponse) { # Filter for supersedence relationships - $SupersedenceRelationships = $Win32AppRelationsResponse | Where-Object { $_.'@odata.type' -eq "#microsoft.graph.mobileAppSupersedence" } - if ($null -ne $SupersedenceRelationships -and $SupersedenceRelationships.Count -gt 0) { - Write-Verbose -Message "Found $(@($SupersedenceRelationships).Count) supersedence relationship(s)" + $SupersedenceRelationships = @($Win32AppRelationsResponse | Where-Object { $_.'@odata.type' -eq "#microsoft.graph.mobileAppSupersedence" }) + if ($SupersedenceRelationships.Count -gt 0) { + Write-Verbose -Message "Found $($SupersedenceRelationships.Count) supersedence relationship(s)" return $SupersedenceRelationships } else {