diff --git a/Private/Test-IntuneWin32AppAssignment.ps1 b/Private/Test-IntuneWin32AppAssignment.ps1 index c9df845..fc30bd6 100644 --- a/Private/Test-IntuneWin32AppAssignment.ps1 +++ b/Private/Test-IntuneWin32AppAssignment.ps1 @@ -12,6 +12,9 @@ function Test-IntuneWin32AppAssignment { .PARAMETER Target Specify the target type of the assignment, AllDevices, AllUsers or Group. + .PARAMETER Intent + Specify the intent of the assignment, either required, available or uninstall. + .NOTES Author: Nickolaj Andersen Contact: @NickolajA @@ -30,7 +33,12 @@ function Test-IntuneWin32AppAssignment { [parameter(Mandatory = $false, HelpMessage = "Specify the target type of the assignment, AllDevices, AllUsers or Group.")] [ValidateNotNullOrEmpty()] [ValidateSet("AllDevices", "AllUsers", "Group")] - [string]$Target + [string]$Target, + + [parameter(Mandatory = $false, HelpMessage = "Specify the intent of the assignment, either required, available or uninstall.")] + [ValidateSet("required", "available", "uninstall")] + [string]$Intent = $null + ) Process { # Handle initial value for duplicate assignment @@ -57,9 +65,9 @@ function Test-IntuneWin32AppAssignment { switch ($Target) { "Group" { foreach ($Win32AppAssignment in $Win32AppAssignments.value) { - if ($Win32AppAssignment.target.'@odata.type' -match "groupAssignmentTarget") { + if ($Win32AppAssignment.target.'@odata.type' -match "groupAssignmentTarget" -and (($null -eq $Intent) -or ($intent -eq $Win32AppAssignment.Intent))) { if ($Win32AppAssignment.target.groupId -like $GroupID) { - Write-Warning -Message "Win32 app assignment with id '$($Win32AppAssignment.id)' of target type '$($Target)' and GroupID '$($Win32AppAssignment.target.groupId)' already exists, duplicate assignments of this type is not permitted" + Write-Warning -Message "Win32 app assignment with id '$($Win32AppAssignment.id)' of target type '$($Target)' and GroupID '$($Win32AppAssignment.target.groupId)' with Intent '$($Intent)' already exists, duplicate assignments of this type is not permitted" $DuplicateAssignmentDetected = $true } } diff --git a/Public/Add-IntuneWin32AppAssignmentGroup.ps1 b/Public/Add-IntuneWin32AppAssignmentGroup.ps1 index bde4ea8..9d87d06 100644 --- a/Public/Add-IntuneWin32AppAssignmentGroup.ps1 +++ b/Public/Add-IntuneWin32AppAssignmentGroup.ps1 @@ -313,7 +313,7 @@ function Add-IntuneWin32AppAssignmentGroup { } } - $DuplicateAssignment = Test-IntuneWin32AppAssignment -ID $Win32AppID -Target "Group" + $DuplicateAssignment = Test-IntuneWin32AppAssignment -ID $Win32AppID -Target "Group" -Intent $Intent if ($DuplicateAssignment -eq $false) { try { # Attempt to call Graph and create new assignment for Win32 app