Skip to content

Updated with autoUpdateSettings parameters #172

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

Closed
wants to merge 3 commits into from
Closed
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
18 changes: 18 additions & 0 deletions Public/Add-IntuneWin32AppAssignmentAllDevices.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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)

Expand Down
18 changes: 18 additions & 0 deletions Public/Add-IntuneWin32AppAssignmentAllUsers.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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)

Expand Down
33 changes: 32 additions & 1 deletion Public/Add-IntuneWin32AppAssignmentGroup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand All @@ -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-19) Updated with autoUpdateSettings parameters
#>
[CmdletBinding(SupportsShouldProcess = $true)]
param(
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -254,6 +263,14 @@ function Add-IntuneWin32AppAssignmentGroup {
"source" = "direct"
"target" = $TargetAssignment
}

# Construct table for autoUpdate settings
if($AutoUpdateSupersededApps -eq "enabled"){if($Win32App.supersededAppCount -eq 0){$AutoUpdateSupersededApps = "notConfigured"}}

$AutoUpdateSettings = @{
"autoUpdateSupersededAppsState" = $AutoUpdateSupersededApps
}

switch ($PSCmdlet.ParameterSetName) {
"GroupInclude" {
$SettingsTable = @{
Expand All @@ -262,6 +279,7 @@ function Add-IntuneWin32AppAssignmentGroup {
"restartSettings" = $null
"deliveryOptimizationPriority" = $DeliveryOptimizationPriority
"installTimeSettings" = $null
"autoUpdateSettings" = $AutoUpdateSettings
}
$Win32AppAssignmentBody.Add("settings", $SettingsTable)
}
Expand All @@ -270,6 +288,19 @@ function Add-IntuneWin32AppAssignmentGroup {
}
}

if ($AutoUpdateSupersededApps -eq "enabled") {
if ($Win32App.supersededAppCount -ne 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 = @{
Expand Down
3 changes: 3 additions & 0 deletions Samples/6-Assignments.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ $AssignmentArgs = @{
"EnableRestartGracePeriod" = $true
"RestartNotificationSnooze" = 220
"Verbose" = $true
"AutoUpdateSupersededApps" = "enabled"
}
Add-IntuneWin32AppAssignmentGroup @AssignmentArgs

Expand Down Expand Up @@ -72,6 +73,7 @@ $AssignmentArgs = @{
"EnableRestartGracePeriod" = $true
"RestartNotificationSnooze" = 220
"Verbose" = $true
"AutoUpdateSupersededApps" = "enabled"
}
Add-IntuneWin32AppAssignmentAllDevices @AssignmentArgs

Expand All @@ -97,5 +99,6 @@ $AssignmentArgs = @{
"EnableRestartGracePeriod" = $true
"RestartNotificationSnooze" = 220
"Verbose" = $true
"AutoUpdateSupersededApps" = "enabled"
}
Add-IntuneWin32AppAssignmentAllUsers @AssignmentArgs