When app has no assignments:
- Get-IntuneWin32AppAssignment v1.4.4 returns nothing, just a warning "WARNING: Empty response for assignments for Win32 app:"
- Get-IntuneWin32AppAssignment v1.5.0 returns 1 assignment entry with all fields empty, except app name.
The problem seems to be in this line:
|
if ($Win32AppAssignmentResponse -ne $null -and $Win32AppAssignmentResponse.Count -gt 0) { |
You should be checking $Win32AppAssignmentResponse.value.Count rather than $Win32AppAssignmentResponse.Count :)
UPDATE: Ok, not that simple it seems.
The problem is that Invoke-MSGraphOperation seems to produce different type of PSCustomObject when the app has no assignments, not what Get-IntuneWin32AppAssignment expects - one with two properties @odata.type and value, which is empty. And therefore Get-IntuneWin32AppAssignment thinks it has 1 assignment to process.
Such object seems to be a raw output of Invoke-RestMethod which you use for Invoke-MSGraphOperation.
How does it escape like this?
As far as i understand, in this response processing block you expect all/empty responses to have @odata.count property which in this case the response doesn't have, therefore it gets processed incorrectly.
|
if ($GraphResponse.'@odata.nextLink' -ne $null) { |
|
$GraphResponseList.AddRange($GraphResponse.value) | Out-Null |
|
$GraphURI = $GraphResponse.'@odata.nextLink' |
|
Write-Verbose -Message "NextLink: $($GraphURI)" |
|
} |
|
else { |
|
# NextLink from response was null, assuming last page but also handle if a single instance is returned |
|
if ($GraphResponse.value) { |
|
$GraphResponseList.AddRange($GraphResponse.value) | Out-Null |
|
} |
|
elseif ($GraphResponse.'@odata.count' -eq 0) { |
|
# Do nothing to return empty |
|
} |
|
else { |
|
$GraphResponseList.Add($GraphResponse) | Out-Null |
|
} |
When app has no assignments:
The problem seems to be in this line:
IntuneWin32App/Public/Get-IntuneWin32AppAssignment.ps1
Line 130 in 875698f
You should be checking
$Win32AppAssignmentResponse.value.Countrather than$Win32AppAssignmentResponse.Count:)UPDATE: Ok, not that simple it seems.
The problem is that
Invoke-MSGraphOperationseems to produce different type of PSCustomObject when the app has no assignments, not what Get-IntuneWin32AppAssignment expects - one with two properties@odata.typeandvalue, which is empty. And therefore Get-IntuneWin32AppAssignment thinks it has 1 assignment to process.Such object seems to be a raw output of
Invoke-RestMethodwhich you use forInvoke-MSGraphOperation.How does it escape like this?
As far as i understand, in this response processing block you expect all/empty responses to have
@odata.countproperty which in this case the response doesn't have, therefore it gets processed incorrectly.IntuneWin32App/Private/Invoke-MSGraphOperation.ps1
Lines 185 to 200 in 875698f