File tree Expand file tree Collapse file tree
CIPPHTTP/Public/Entrypoints/HTTP Functions/Endpoint/Applications Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -32,14 +32,16 @@ function New-CIPPIntuneAppDeployment {
3232 if (-not $PackageId ) {
3333 throw " PackageName/packagename is required for WinGet apps but was not found in the config for '$AppDisplayName '."
3434 }
35+ # Default to system when InstallAsSystem is absent so existing templates keep their behavior
36+ $RunAsAccount = if ($null -ne $AppConfig.InstallAsSystem -and -not [bool ]$AppConfig.InstallAsSystem ) { ' user' } else { ' system' }
3537 $IntuneBody = [ordered ]@ {
3638 ' @odata.type' = ' #microsoft.graph.winGetApp'
3739 ' displayName' = " $AppDisplayName "
3840 ' description' = " $ ( $AppConfig.description ) "
3941 ' packageIdentifier' = " $PackageId "
4042 ' installExperience' = @ {
4143 ' @odata.type' = ' microsoft.graph.winGetAppInstallExperience'
42- ' runAsAccount' = ' system '
44+ ' runAsAccount' = $RunAsAccount
4345 }
4446 }
4547 }
Original file line number Diff line number Diff line change @@ -15,15 +15,17 @@ function Invoke-AddStoreApp {
1515 $WinGetApp = $Request.Body
1616 $assignTo = $Request.Body.AssignTo -eq ' customGroup' ? $Request.Body.CustomGroup : $Request.Body.AssignTo
1717
18- if ($ChocoApp.InstallAsSystem ) { ' system' } else { ' user' }
18+ # winGetAppInstallExperience only supports runAsAccount (no restart behavior). Default to
19+ # system when the toggle is absent so older callers keep the previous behavior.
20+ $RunAsAccount = if ($null -ne $WinGetApp.InstallAsSystem -and -not [bool ]$WinGetApp.InstallAsSystem ) { ' user' } else { ' system' }
1921 $WinGetData = [ordered ]@ {
2022 ' @odata.type' = ' #microsoft.graph.winGetApp'
2123 ' displayName' = " $ ( $WinGetApp.ApplicationName ) "
2224 ' description' = " $ ( $WinGetApp.description ) "
2325 ' packageIdentifier' = " $ ( $WinGetApp.PackageName ) "
2426 ' installExperience' = @ {
2527 ' @odata.type' = ' microsoft.graph.winGetAppInstallExperience'
26- ' runAsAccount' = ' system '
28+ ' runAsAccount' = $RunAsAccount
2729 }
2830 }
2931 $AllowedTenants = Test-CIPPAccess - Request $Request - TenantList
You can’t perform that action at this time.
0 commit comments