Fix Get-IntuneWin32AppSupersedence.ps1 logic for single-item responses#224
Open
Marco-Valle wants to merge 1 commit intoMSEndpointMgr:masterfrom
Open
Fix Get-IntuneWin32AppSupersedence.ps1 logic for single-item responses#224Marco-Valle wants to merge 1 commit intoMSEndpointMgr:masterfrom
Marco-Valle wants to merge 1 commit intoMSEndpointMgr:masterfrom
Conversation
* 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR resolves an issue where
Get-IntuneWin32AppSupersedencefails to return data in Windows PowerShell 5.1 when exactly one relationship exists.In Windows PowerShell,
[PSCustomObject]scalars do not have an intrinsic.Countproperty. By switching to a$nullcheck and using the@()array subexpression, we ensure consistent behavior across PS 5.1 and PS 7+.Related Issue
Fixes #223
Changes
Get-IntuneWin32AppSupersedence.ps1to handle scalar Graph responses..Countis always valid for logic and verbose logging.Testing
Environment
Verified on:
Output
The following code snippet shows the output of the execution in PowerShell 5.1, where the issue occurs.