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

Auto-Update Flag for available deployments #158

Open
AlkHacNar opened this issue Apr 29, 2024 · 9 comments · May be fixed by #167
Open

Auto-Update Flag for available deployments #158

AlkHacNar opened this issue Apr 29, 2024 · 9 comments · May be fixed by #167

Comments

@AlkHacNar
Copy link

With the Intune [2404] Update came finally the auto-update function for available apps, if supersedence is set. Could we get it with the next update pls ;-)

Greetings

Alexej

@PZan
Copy link

PZan commented May 23, 2024

Would love to see this being implemented as well.

@aCID-sLAM
Copy link

Thanks @AlkHacNar , i missed that one. Finally the updates are usable now. Now a support in the module would round everything up.

@AlkHacNar
Copy link
Author

@kenchan0130 I get an error with your fix
WARNING: An error occurred while creating a Win32 app assignment. Error message: ModelValidationFailure: The property 'autoUpdateSupersededApps' does not exist on type 'microsoft.management.services.api.win32LobAppAuto UpdateSettings'. Make sure to only use property names that are defined by the type.

@AlkHacNar AlkHacNar reopened this Jul 25, 2024
@ChristianOe
Copy link

@AlkHacNar: They changed the api a little bit.
Instead of:

Construct table for autoUpdate settings

$AutoUpdateSettings = @{
    "autoUpdateSupersededApps" = $AutoUpdateSupersededApps

}

Use:

Construct table for autoUpdate settings

$AutoUpdateSettings = @{
    "autoUpdateSupersededAppsState" = $AutoUpdateSupersededApps

}

The api looks like this:
"settings": {
"@odata.type": "#microsoft.graph.win32LobAppAssignmentSettings",
"notifications": "showAll",
"restartSettings": null,
"installTimeSettings": null,
"deliveryOptimizationPriority": "foreground",
"autoUpdateSettings": {
"autoUpdateSupersededAppsState": "enabled"
}
}

@AlkHacNar
Copy link
Author

if I use the $AutoUpdateSupersededApps param on an app which don't have a supersedence, does it throw a failure?^^ I'm gonna test it

@ChristianOe
Copy link

You can look in my fork (https://github.com/ChristianOe/IntuneWin32App)
There I have a working example in Add-IntuneWin32AppAssignmentGroup.ps1

@AlkHacNar
Copy link
Author

AlkHacNar commented Aug 16, 2024

@ChristianOe: thx a lot now I get it to work. and made a workaroud for my script
just one thing, maybe it would be better to do it like this? just my 2 cents, yours works like a charm too^^
Instead of:

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

switch ($PSCmdlet.ParameterSetName) {
                "GroupInclude" {
                    $SettingsTable = @{
                        "@odata.type" = "#microsoft.graph.win32LobAppAssignmentSettings"
                        "notifications" = $Notification
                        "restartSettings" = $null
                        "deliveryOptimizationPriority" = $DeliveryOptimizationPriority
                        "autoUpdateSettings" = $null
                        "installTimeSettings" = $null
                    }
                    $Win32AppAssignmentBody.Add("settings", $SettingsTable)
                }
                "GroupExclude" {
                    $Win32AppAssignmentBody.Add("settings", $null)
                }
            }

            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."
                }
            }

maybe like this?

if($AutoUpdateSupersededApps -eq "enabled"){if($Win32App.supersededAppCount -eq 0){$AutoUpdateSupersededApps = "notConfigured"}}
$AutoUpdateSettings = @{
                "autoUpdateSupersededAppsState" = $AutoUpdateSupersededApps
            }

            switch ($PSCmdlet.ParameterSetName) {
                "GroupInclude" {
                    $SettingsTable = @{
                        "@odata.type" = "#microsoft.graph.win32LobAppAssignmentSettings"
                        "notifications" = $Notification
                        "restartSettings" = $null
                        "deliveryOptimizationPriority" = $DeliveryOptimizationPriority
                        "installTimeSettings" = $null
                        "autoUpdateSettings" = $AutoUpdateSettings
                    }
                    $Win32AppAssignmentBody.Add("settings", $SettingsTable)
                }
                "GroupExclude" {
                    $Win32AppAssignmentBody.Add("settings", $null)
                }
            }

if someone don't want to change the file "manually" here my workaround (I always uninstall old versions, so I onyl have one, if you have more then one you need wto do it with index)

[version]$moduleversion = (Get-InstalledModule -Name IntuneWin32App).version
$module = Get-Content "C:\Program Files\WindowsPowerShell\Modules\IntuneWin32App\$moduleversion\Public\Add-IntuneWin32AppAssignmentGroup.ps1"
if($module.Count -lt 349)
{
    Remove-Module -Name IntuneWin32App -ErrorAction SilentlyContinue
    $newmodule = @()
    $newmodule += $module[0..37]
    $newmodule += "    .PARAMETER AutoUpdateSupersededApps"
    $newmodule += "        Specify to automatically update superseded app using default value of `'notConfigured`'."
    $newmodule += " "
    $newmodule += $module[38..115]
    $newmodule += "        [parameter(Mandatory = `$false, HelpMessage = `"Specify to automatically update superseded app using default value of `'notConfigured`'.`")]"
    $newmodule += "        [ValidateNotNullOrEmpty()]"
    $newmodule += "        [ValidateSet(`"notConfigured`", `"enabled`", `"unknownFutureValue`")]"
    $newmodule += "        [string]`$AutoUpdateSupersededApps = `"notConfigured`","
    $newmodule += " "
    $newmodule += $module[116..255]
    $newmodule += "            if(`$AutoUpdateSupersededApps -eq `"enabled`"){if(`$Win32App.supersededAppCount -eq 0){`$AutoUpdateSupersededApps = `"notConfigured`"}}"
    $newmodule += $module[256..257]
    $newmodule += "                    # Construct table for autoUpdate settings"
    $newmodule += "                    `$AutoUpdateSettings = @{"
    $newmodule += "                        `"autoUpdateSupersededAppsState`" = `$AutoUpdateSupersededApps"
    $newmodule += "                    }"
    $newmodule += $module[258..263]
    $newmodule += "                        `"autoUpdateSettings`" = `$AutoUpdateSettings"
    $newmodule += $module[264..($module.Count-1)]
    Set-Content "C:\Program Files\WindowsPowerShell\Modules\IntuneWin32App\$moduleversion\Public\Add-IntuneWin32AppAssignmentGroup.ps1" $newmodule
    Import-Module -Name IntuneWin32App
}

@ChristianOe
Copy link

@AlkHacNar that's looks nice. Time to implement it in the project to all functions to get it live hopefully :-)

@ChristianOe
Copy link

@AlkHacNar I have updatet the AutoUpdate Feature in #175. Its needed because the flag only works with Intent available but not for required or uninstall.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants