Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 29 additions & 9 deletions Public/Get-IntuneWin32AppAssignment.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -178,22 +178,42 @@ function Get-IntuneWin32AppAssignment {
}
else {
foreach ($Win32AppAssignment in $Win32AppAssignmentResponse.value) {
# Determine if assignment is either Include or Exclude for GroupMode property output
switch ($Win32AppAssignment.target.'@odata.type') {
# Determine if assignment is either Include or Exclude for GroupMode property output
switch ($Win32AppAssignment.target.'@odata.type') {
"#microsoft.graph.groupAssignmentTarget" {
$GroupMode = "Include"
}
"#microsoft.graph.exclusionGroupAssignmentTarget" {
$GroupMode = "Exclude"
}
"#microsoft.graph.allDevicesAssignmentTarget" {
$GroupMode = "Include"
}
"#microsoft.graph.allLicensedUsersAssignmentTarget" {
$GroupMode = "Include"
}
}

# If data type is of type 'groupAssignmentTarget' then retrieve group name from given group id
# If data type is of type 'groupAssignmentTarget' then retrieve group name from given group id
if ($Win32AppAssignment.target.'@odata.type' -like '*groupAssignmentTarget') {
$AzureADGroupResponse = Invoke-AzureADGraphRequest -Resource "groups/$($Win32AppAssignment.target.groupId)" -Method "GET"
}
else {
$AzureADGroupResponse = $null

if ($AzureADGroupResponse -ne $null)
{
$GroupNameObject = $AzureADGroupResponse.displayName
}
}
elseif ($Win32AppAssignment.target.'@odata.type' -like '*allDevicesAssignmentTarget')
{
$GroupNameObject = "All Devices"
}
elseif ($Win32AppAssignment.target.'@odata.type' -like '*allLicensedUsersAssignmentTarget')
{
$GroupNameObject = "All Users"
}
else
{
$GroupNameObject = $null
}

# Create a custom object for return value
Expand All @@ -203,7 +223,7 @@ function Get-IntuneWin32AppAssignment {
FilterID = $Win32AppAssignment.target.deviceAndAppManagementAssignmentFilterId
FilterType = $Win32AppAssignment.target.deviceAndAppManagementAssignmentFilterType
GroupID = $Win32AppAssignment.target.groupId
GroupName = if ($AzureADGroupResponse -ne $null) { $AzureADGroupResponse.displayName } else { $null }
GroupName = $GroupNameObject
Intent = $Win32AppAssignment.intent
GroupMode = $GroupMode
DeliveryOptimizationPriority = $Win32AppAssignment.settings.deliveryOptimizationPriority
Expand All @@ -228,4 +248,4 @@ function Get-IntuneWin32AppAssignment {
return $Win32AppAssignmentList
}
}
}
}