Skip to content

Commit b37bb3d

Browse files
add as system for store apps
Synced from CyberDrain/CIPP@0cdc800
1 parent 7c373c5 commit b37bb3d

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

Modules/CIPPCore/Public/New-CIPPIntuneAppDeployment.ps1

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff 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
}

Modules/CIPPHTTP/Public/Entrypoints/HTTP Functions/Endpoint/Applications/Invoke-AddStoreApp.ps1

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)