Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Same Groups on different intents in AppAssignment #141

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
14 changes: 11 additions & 3 deletions Private/Test-IntuneWin32AppAssignment.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
}
}
Expand Down
2 changes: 1 addition & 1 deletion Public/Add-IntuneWin32AppAssignmentGroup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down