From 1d9b177dd15f14de50bdec90be90d41ef4feee3a Mon Sep 17 00:00:00 2001 From: Christian Oeser Date: Fri, 16 Aug 2024 15:21:33 +0200 Subject: [PATCH 1/3] Added AutoUpdateSupersededApps to GroupAssignment --- Public/Add-IntuneWin32AppAssignmentGroup.ps1 | 31 +++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/Public/Add-IntuneWin32AppAssignmentGroup.ps1 b/Public/Add-IntuneWin32AppAssignmentGroup.ps1 index 69c211a..b37a515 100644 --- a/Public/Add-IntuneWin32AppAssignmentGroup.ps1 +++ b/Public/Add-IntuneWin32AppAssignmentGroup.ps1 @@ -29,6 +29,9 @@ function Add-IntuneWin32AppAssignmentGroup { .PARAMETER DeadlineTime Specify a date time object for the deadline of the assignment. + + .PARAMETER AutoUpdateSupersededApps + Specify to automatically update superseded app using default value of 'notConfigured'. .PARAMETER UseLocalTime Specify to use either UTC of device local time for the assignment, set to 'True' for device local time and 'False' for UTC. @@ -58,7 +61,7 @@ function Add-IntuneWin32AppAssignmentGroup { Author: Nickolaj Andersen Contact: @NickolajA Created: 2020-09-20 - Updated: 2023-09-20 + Updated: 2024-08-16 Version history: 1.0.0 - (2020-09-20) Function created @@ -67,6 +70,7 @@ function Add-IntuneWin32AppAssignmentGroup { 1.0.3 - (2021-08-31) Updated to use new authentication header 1.0.4 - (2023-09-04) Updated with Test-AccessToken function 1.0.5 - (2023-09-20) Updated with FilterName and FilterMode parameters + 1.0.6 - (2024-08-16) Updated with autoUpdateSettings parameters #> [CmdletBinding(SupportsShouldProcess = $true)] param( @@ -114,6 +118,11 @@ function Add-IntuneWin32AppAssignmentGroup { [ValidateSet("notConfigured", "foreground")] [string]$DeliveryOptimizationPriority = "notConfigured", + [parameter(Mandatory = $false, HelpMessage = "Specify to automatically update superseded app using default value of 'notConfigured'.")] + [ValidateNotNullOrEmpty()] + [ValidateSet("notConfigured", "enabled", "unknownFutureValue")] + [string]$AutoUpdateSupersededApps = "notConfigured", + [parameter(Mandatory = $false, ParameterSetName = "GroupInclude", HelpMessage = "Specify whether Restart Grace Period functionality for this assignment should be configured, additional parameter input using at least RestartGracePeriod and RestartCountDownDisplay is required.")] [ValidateNotNullOrEmpty()] [bool]$EnableRestartGracePeriod = $false, @@ -254,6 +263,12 @@ function Add-IntuneWin32AppAssignmentGroup { "source" = "direct" "target" = $TargetAssignment } + + # Construct table for autoUpdate settings + $AutoUpdateSettings = @{ + "autoUpdateSupersededAppsState" = $AutoUpdateSupersededApps + } + switch ($PSCmdlet.ParameterSetName) { "GroupInclude" { $SettingsTable = @{ @@ -261,6 +276,7 @@ function Add-IntuneWin32AppAssignmentGroup { "notifications" = $Notification "restartSettings" = $null "deliveryOptimizationPriority" = $DeliveryOptimizationPriority + "autoUpdateSettings" = $null "installTimeSettings" = $null } $Win32AppAssignmentBody.Add("settings", $SettingsTable) @@ -270,6 +286,19 @@ function Add-IntuneWin32AppAssignmentGroup { } } + if ($AutoUpdateSupersededApps -eq "enable") { + if ($Win32App.supersededAppCount -gt 0) { + Write-Verbose -Message "Detected that Win32 app has an app to supersed" + + $Win32AppAssignmentBody.settings.autoUpdateSettings = @{ + "autoUpdateSupersededAppsState" = $AutoUpdateSupersededApps + } + } + else { + Write-Warning -Message "Win32 app was not configured for superseding an app. Please add a superseding relationship." + } + } + # Amend installTimeSettings property if Available parameter is specified if (($PSBoundParameters["AvailableTime"]) -and (-not($PSBoundParameters["DeadlineTime"]))) { $Win32AppAssignmentBody.settings.installTimeSettings = @{ From 775b17ea00fba27417bf2c1233e3817bf159304a Mon Sep 17 00:00:00 2001 From: Christian Oeser Date: Fri, 16 Aug 2024 15:37:43 +0200 Subject: [PATCH 2/3] fixed autoupodate --- Public/Add-IntuneWin32AppAssignmentGroup.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Public/Add-IntuneWin32AppAssignmentGroup.ps1 b/Public/Add-IntuneWin32AppAssignmentGroup.ps1 index b37a515..20d03ea 100644 --- a/Public/Add-IntuneWin32AppAssignmentGroup.ps1 +++ b/Public/Add-IntuneWin32AppAssignmentGroup.ps1 @@ -286,8 +286,8 @@ function Add-IntuneWin32AppAssignmentGroup { } } - if ($AutoUpdateSupersededApps -eq "enable") { - if ($Win32App.supersededAppCount -gt 0) { + if ($AutoUpdateSupersededApps -eq "enabled") { + if ($Win32App.supersededAppCount -ne 0) { Write-Verbose -Message "Detected that Win32 app has an app to supersed" $Win32AppAssignmentBody.settings.autoUpdateSettings = @{ From 7600acb5a0c8e5523bbfec373f4b57e56702dfde Mon Sep 17 00:00:00 2001 From: Christian Oeser Date: Mon, 19 Aug 2024 12:24:06 +0200 Subject: [PATCH 3/3] Updated with autoUpdateSettings parameters --- .../Add-IntuneWin32AppAssignmentAllDevices.ps1 | 18 ++++++++++++++++++ .../Add-IntuneWin32AppAssignmentAllUsers.ps1 | 18 ++++++++++++++++++ Public/Add-IntuneWin32AppAssignmentGroup.ps1 | 6 ++++-- Samples/6-Assignments.ps1 | 3 +++ 4 files changed, 43 insertions(+), 2 deletions(-) diff --git a/Public/Add-IntuneWin32AppAssignmentAllDevices.ps1 b/Public/Add-IntuneWin32AppAssignmentAllDevices.ps1 index 02d33d2..d35deee 100644 --- a/Public/Add-IntuneWin32AppAssignmentAllDevices.ps1 +++ b/Public/Add-IntuneWin32AppAssignmentAllDevices.ps1 @@ -21,6 +21,9 @@ function Add-IntuneWin32AppAssignmentAllDevices { .PARAMETER DeadlineTime Specify a date time object for the deadline of the assignment. + .PARAMETER AutoUpdateSupersededApps + Specify to automatically update superseded app using default value of 'notConfigured'. + .PARAMETER UseLocalTime Specify to use either UTC of device local time for the assignment, set to 'True' for device local time and 'False' for UTC. @@ -56,6 +59,7 @@ function Add-IntuneWin32AppAssignmentAllDevices { 1.0.1 - (2021-04-01) Updated token expired message to a warning instead of verbose output 1.0.2 - (2021-08-31) Updated to use new authentication header 1.0.3 - (2023-09-04) Updated with Test-AccessToken function + 1.0.4 - (2024-08-19) Updated with autoUpdateSettings parameters #> [CmdletBinding(SupportsShouldProcess = $true)] param( @@ -90,6 +94,11 @@ function Add-IntuneWin32AppAssignmentAllDevices { [ValidateSet("notConfigured", "foreground")] [string]$DeliveryOptimizationPriority = "notConfigured", + [parameter(Mandatory = $false, HelpMessage = "Specify to automatically update superseded app using default value of 'notConfigured'.")] + [ValidateNotNullOrEmpty()] + [ValidateSet("notConfigured", "enabled", "unknownFutureValue")] + [string]$AutoUpdateSupersededApps = "notConfigured", + [parameter(Mandatory = $false, HelpMessage = "Specify whether Restart Grace Period functionality for this assignment should be configured, additional parameter input using at least RestartGracePeriod and RestartCountDownDisplay is required.")] [ValidateNotNullOrEmpty()] [bool]$EnableRestartGracePeriod = $false, @@ -206,12 +215,21 @@ function Add-IntuneWin32AppAssignmentAllDevices { "source" = "direct" "target" = $TargetAssignment } + + # Construct table for autoUpdate settings + if($AutoUpdateSupersededApps -eq "enabled"){if($Win32App.supersededAppCount -eq 0){$AutoUpdateSupersededApps = "notConfigured"}} + + $AutoUpdateSettings = @{ + "autoUpdateSupersededAppsState" = $AutoUpdateSupersededApps + } + $SettingsTable = @{ "@odata.type" = "#microsoft.graph.win32LobAppAssignmentSettings" "notifications" = $Notification "restartSettings" = $null "deliveryOptimizationPriority" = $DeliveryOptimizationPriority "installTimeSettings" = $null + "autoUpdateSettings" = $AutoUpdateSettings } $Win32AppAssignmentBody.Add("settings", $SettingsTable) diff --git a/Public/Add-IntuneWin32AppAssignmentAllUsers.ps1 b/Public/Add-IntuneWin32AppAssignmentAllUsers.ps1 index 7618fac..e762a11 100644 --- a/Public/Add-IntuneWin32AppAssignmentAllUsers.ps1 +++ b/Public/Add-IntuneWin32AppAssignmentAllUsers.ps1 @@ -21,6 +21,9 @@ function Add-IntuneWin32AppAssignmentAllUsers { .PARAMETER DeadlineTime Specify a date time object for the deadline of the assignment. + .PARAMETER AutoUpdateSupersededApps + Specify to automatically update superseded app using default value of 'notConfigured'. + .PARAMETER UseLocalTime Specify to use either UTC of device local time for the assignment, set to 'True' for device local time and 'False' for UTC. @@ -56,6 +59,7 @@ function Add-IntuneWin32AppAssignmentAllUsers { 1.0.1 - (2021-04-01) Updated token expired message to a warning instead of verbose output 1.0.2 - (2021-08-31) Updated to use new authentication header 1.0.3 - (2023-09-04) Updated with Test-AccessToken function + 1.0.4 - (2024-08-19) Updated with autoUpdateSettings parameters #> [CmdletBinding(SupportsShouldProcess = $true)] param( @@ -90,6 +94,11 @@ function Add-IntuneWin32AppAssignmentAllUsers { [ValidateSet("notConfigured", "foreground")] [string]$DeliveryOptimizationPriority = "notConfigured", + [parameter(Mandatory = $false, HelpMessage = "Specify to automatically update superseded app using default value of 'notConfigured'.")] + [ValidateNotNullOrEmpty()] + [ValidateSet("notConfigured", "enabled", "unknownFutureValue")] + [string]$AutoUpdateSupersededApps = "notConfigured", + [parameter(Mandatory = $false, HelpMessage = "Specify whether Restart Grace Period functionality for this assignment should be configured, additional parameter input using at least RestartGracePeriod and RestartCountDownDisplay is required.")] [ValidateNotNullOrEmpty()] [bool]$EnableRestartGracePeriod = $false, @@ -206,12 +215,21 @@ function Add-IntuneWin32AppAssignmentAllUsers { "source" = "direct" "target" = $TargetAssignment } + + # Construct table for autoUpdate settings + if($AutoUpdateSupersededApps -eq "enabled"){if($Win32App.supersededAppCount -eq 0){$AutoUpdateSupersededApps = "notConfigured"}} + + $AutoUpdateSettings = @{ + "autoUpdateSupersededAppsState" = $AutoUpdateSupersededApps + } + $SettingsTable = @{ "@odata.type" = "#microsoft.graph.win32LobAppAssignmentSettings" "notifications" = $Notification "restartSettings" = $null "deliveryOptimizationPriority" = $DeliveryOptimizationPriority "installTimeSettings" = $null + "autoUpdateSettings" = $AutoUpdateSettings } $Win32AppAssignmentBody.Add("settings", $SettingsTable) diff --git a/Public/Add-IntuneWin32AppAssignmentGroup.ps1 b/Public/Add-IntuneWin32AppAssignmentGroup.ps1 index 20d03ea..bb23ae8 100644 --- a/Public/Add-IntuneWin32AppAssignmentGroup.ps1 +++ b/Public/Add-IntuneWin32AppAssignmentGroup.ps1 @@ -70,7 +70,7 @@ function Add-IntuneWin32AppAssignmentGroup { 1.0.3 - (2021-08-31) Updated to use new authentication header 1.0.4 - (2023-09-04) Updated with Test-AccessToken function 1.0.5 - (2023-09-20) Updated with FilterName and FilterMode parameters - 1.0.6 - (2024-08-16) Updated with autoUpdateSettings parameters + 1.0.6 - (2024-08-19) Updated with autoUpdateSettings parameters #> [CmdletBinding(SupportsShouldProcess = $true)] param( @@ -265,6 +265,8 @@ function Add-IntuneWin32AppAssignmentGroup { } # Construct table for autoUpdate settings + if($AutoUpdateSupersededApps -eq "enabled"){if($Win32App.supersededAppCount -eq 0){$AutoUpdateSupersededApps = "notConfigured"}} + $AutoUpdateSettings = @{ "autoUpdateSupersededAppsState" = $AutoUpdateSupersededApps } @@ -276,8 +278,8 @@ function Add-IntuneWin32AppAssignmentGroup { "notifications" = $Notification "restartSettings" = $null "deliveryOptimizationPriority" = $DeliveryOptimizationPriority - "autoUpdateSettings" = $null "installTimeSettings" = $null + "autoUpdateSettings" = $AutoUpdateSettings } $Win32AppAssignmentBody.Add("settings", $SettingsTable) } diff --git a/Samples/6-Assignments.ps1 b/Samples/6-Assignments.ps1 index 8afe583..ba3fcda 100644 --- a/Samples/6-Assignments.ps1 +++ b/Samples/6-Assignments.ps1 @@ -32,6 +32,7 @@ $AssignmentArgs = @{ "EnableRestartGracePeriod" = $true "RestartNotificationSnooze" = 220 "Verbose" = $true + "AutoUpdateSupersededApps" = "enabled" } Add-IntuneWin32AppAssignmentGroup @AssignmentArgs @@ -72,6 +73,7 @@ $AssignmentArgs = @{ "EnableRestartGracePeriod" = $true "RestartNotificationSnooze" = 220 "Verbose" = $true + "AutoUpdateSupersededApps" = "enabled" } Add-IntuneWin32AppAssignmentAllDevices @AssignmentArgs @@ -97,5 +99,6 @@ $AssignmentArgs = @{ "EnableRestartGracePeriod" = $true "RestartNotificationSnooze" = 220 "Verbose" = $true + "AutoUpdateSupersededApps" = "enabled" } Add-IntuneWin32AppAssignmentAllUsers @AssignmentArgs \ No newline at end of file