The Issue
There is a logic failure in Get-IntuneWin32AppSupersedence.ps1 that prevents the function from returning results in Windows PowerShell 5.1 when an app has exactly one supersedence relationship.
In PowerShell 5.1, a single [PSCustomObject] (scalar) does not have a .Count property (it returns $null). The current code checks if ($Win32AppRelationsResponse.Count -gt 0), which fails for single objects in 5.1, even though it works in PowerShell 7+.
Environment
- OS: Windows 11
- PowerShell Version: 5.1 (and 7.6 for comparison)
- Module: IntuneWin32App
Steps to Reproduce
PowerShell 7.6 (Working)
In PS 7.6, the engine correctly identifies the scalar as having a count of 1.
PS C:\> Get-IntuneWin32AppSupersedence -ID "bcce6ee9-d839-46c3-b489-e6014345b7ef"
VERBOSE: Querying for Win32 app using ID: bcce6ee9-d839-46c3-b489-e6014345b7ef
VERBOSE: GET https://graph.microsoft.com/Beta/deviceAppManagement/mobileApps/bcce6ee9-d839-46c3-b489-e6014345b7ef
VERBOSE: GET https://graph.microsoft.com/Beta/deviceAppManagement/mobileApps/bcce6ee9-d839-46c3-b489-e6014345b7ef/relationships
VERBOSE: Found 1 supersedence relationship(s)
# [Object Data Returned Successfully]
PowerShell 5.1 (Broken)
In PS 5.1, the function silently exits after the Graph call because the .Count check fails.
PS C:\> Get-IntuneWin32AppSupersedence -ID "bcce6ee9-d839-46c3-b489-e6014345b7ef"
VERBOSE: Querying for Win32 app using ID: bcce6ee9-d839-46c3-b489-e6014345b7ef
VERBOSE: GET https://graph.microsoft.com/Beta/deviceAppManagement/mobileApps/bcce6ee9-d839-46c3-b489-e6014345b7ef
VERBOSE: GET https://graph.microsoft.com/Beta/deviceAppManagement/mobileApps/bcce6ee9-d839-46c3-b489-e6014345b7ef/relationships
PS C:\> # [No data returned, script stopped at the .Count check]
The Issue
There is a logic failure in Get-IntuneWin32AppSupersedence.ps1 that prevents the function from returning results in Windows PowerShell 5.1 when an app has exactly one supersedence relationship.
In PowerShell 5.1, a single [PSCustomObject] (scalar) does not have a .Count property (it returns $null). The current code checks if ($Win32AppRelationsResponse.Count -gt 0), which fails for single objects in 5.1, even though it works in PowerShell 7+.
Environment
Steps to Reproduce
PowerShell 7.6 (Working)
In PS 7.6, the engine correctly identifies the scalar as having a count of 1.
PowerShell 5.1 (Broken)
In PS 5.1, the function silently exits after the Graph call because the .Count check fails.