Skip to content

Commit d98d37e

Browse files
Merge pull request KelvinTegelaar#1896 from kris6673/ap-language
feat: Map 'user-select' language to empty string in Autopilot profile
2 parents ac1d5fb + 029dcc4 commit d98d37e

3 files changed

Lines changed: 21 additions & 17 deletions

File tree

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Endpoint/Autopilot/Invoke-AddAutopilotConfig.ps1

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ function Invoke-AddAutopilotConfig {
88
[CmdletBinding()]
99
param($Request, $TriggerMetadata)
1010
# Input bindings are passed in via param block.
11+
$APIName = $Request.Params.CIPPEndpoint
12+
$Headers = $Request.Headers
1113
$Tenants = $Request.Body.selectedTenants.value
1214
$Profbod = [pscustomobject]$Request.Body
1315
$UserType = if ($Profbod.NotLocalAdmin -eq 'true') { 'standard' } else { 'administrator' }
@@ -30,6 +32,8 @@ function Invoke-AddAutopilotConfig {
3032
HideTerms = $Profbod.HideTerms
3133
Autokeyboard = $Profbod.Autokeyboard
3234
Language = $ProfBod.languages.value
35+
Headers = $Headers
36+
APIName = $APIName
3337
}
3438
$Results = foreach ($tenant in $Tenants) {
3539
$profileParams['tenantFilter'] = $tenant

Modules/CIPPCore/Public/Set-CIPPDefaultAPDeploymentProfile.ps1

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ function Set-CIPPDefaultAPDeploymentProfile {
1919
$APIName = 'Add Default Autopilot Deployment Profile'
2020
)
2121

22-
$User = $Request.Headers
23-
2422
try {
23+
if ($Language -eq 'user-select') { $Language = '' }
24+
2525
$ObjBody = [pscustomobject]@{
2626
'@odata.type' = '#microsoft.graph.azureADWindowsAutopilotDeploymentProfile'
2727
'displayName' = "$($DisplayName)"
2828
'description' = "$($Description)"
2929
'deviceNameTemplate' = "$($DeviceNameTemplate)"
30-
'locale' = "$($Language ?? 'os-default')"
30+
'locale' = "$($Language)"
3131
'preprovisioningAllowed' = $([bool]($AllowWhiteGlove))
3232
'deviceType' = 'windowsPc'
3333
'hardwareHashExtractionEnabled' = $([bool]($CollectHash))
@@ -51,7 +51,7 @@ function Set-CIPPDefaultAPDeploymentProfile {
5151
if ($_.id -ne $Profiles[0].id) {
5252
if ($PSCmdlet.ShouldProcess($_.displayName, 'Delete duplicate Autopilot profile')) {
5353
$null = New-GraphPOSTRequest -uri "https://graph.microsoft.com/beta/deviceManagement/windowsAutopilotDeploymentProfiles/$($_.id)" -tenantid $TenantFilter -type DELETE
54-
Write-LogMessage -Headers $User -API $APIName -tenant $($TenantFilter) -message "Deleted duplicate Autopilot profile $($DisplayName)" -Sev 'Info'
54+
Write-LogMessage -Headers $Headers -API $APIName -tenant $($TenantFilter) -message "Deleted duplicate Autopilot profile $($DisplayName)" -Sev 'Info'
5555
}
5656
}
5757
}
@@ -61,7 +61,7 @@ function Set-CIPPDefaultAPDeploymentProfile {
6161
if ($PSCmdlet.ShouldProcess($DisplayName, 'Add Autopilot profile')) {
6262
$Type = 'Add'
6363
$GraphRequest = New-GraphPostRequest -uri 'https://graph.microsoft.com/beta/deviceManagement/windowsAutopilotDeploymentProfiles' -body $Body -tenantid $TenantFilter
64-
Write-LogMessage -Headers $User -API $APIName -tenant $($TenantFilter) -message "Added Autopilot profile $($DisplayName)" -Sev 'Info'
64+
Write-LogMessage -Headers $Headers -API $APIName -tenant $($TenantFilter) -message "Added Autopilot profile $($DisplayName)" -Sev 'Info'
6565
}
6666
} else {
6767
$Type = 'Edit'
@@ -78,18 +78,18 @@ function Set-CIPPDefaultAPDeploymentProfile {
7878
if (!$Assignments) {
7979
$null = New-GraphPOSTRequest -uri "https://graph.microsoft.com/beta/deviceManagement/windowsAutopilotDeploymentProfiles/$($GraphRequest.id)/assignments" -tenantid $TenantFilter -type POST -body $AssignBody
8080
}
81-
Write-LogMessage -Headers $User -API $APIName -tenant $TenantFilter -message "Assigned autopilot profile $($DisplayName) to $($AssignTo)" -Sev 'Info'
81+
Write-LogMessage -Headers $Headers -API $APIName -tenant $TenantFilter -message "Assigned autopilot profile $($DisplayName) to $($AssignTo)" -Sev 'Info'
8282
}
8383
} catch {
8484
$ErrorMessage = Get-CippException -Exception $_
85-
Write-LogMessage -Headers $User -API $APIName -tenant $TenantFilter -message "Failed to assign Autopilot profile $($DisplayName) to $($AssignTo): $($ErrorMessage.NormalizedError)" -Sev 'Error' -LogData $ErrorMessage
85+
Write-LogMessage -Headers $Headers -API $APIName -tenant $TenantFilter -message "Failed to assign Autopilot profile $($DisplayName) to $($AssignTo): $($ErrorMessage.NormalizedError)" -Sev 'Error' -LogData $ErrorMessage
8686
}
8787
}
8888
"Successfully $($Type)ed profile for $($TenantFilter)"
8989
} catch {
9090
$ErrorMessage = Get-CippException -Exception $_
9191
$Result = "Failed $($Type)ing Autopilot Profile $($DisplayName). Error: $($ErrorMessage.NormalizedError)"
92-
Write-LogMessage -Headers $User -API $APIName -tenant $TenantFilter -message $Result -Sev 'Error' -LogData $ErrorMessage
92+
Write-LogMessage -Headers $Headers -API $APIName -tenant $TenantFilter -message $Result -Sev 'Error' -LogData $ErrorMessage
9393
throw $Result
9494
}
9595
}

Modules/CIPPCore/Public/Standards/Invoke-CIPPStandardAutopilotProfile.ps1

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -110,18 +110,18 @@ function Invoke-CIPPStandardAutopilotProfile {
110110
} else {
111111
try {
112112
$Parameters = @{
113-
tenantFilter = $Tenant
114-
displayName = $Settings.DisplayName
115-
description = $Settings.Description
116-
userType = $userType
113+
TenantFilter = $Tenant
114+
DisplayName = $Settings.DisplayName
115+
Description = $Settings.Description
116+
UserType = $userType
117117
DeploymentMode = $DeploymentMode
118118
AssignTo = $Settings.AssignToAllDevices
119-
devicenameTemplate = $Settings.DeviceNameTemplate
120-
allowWhiteGlove = $Settings.AllowWhiteGlove
119+
DeviceNameTemplate = $Settings.DeviceNameTemplate
120+
AllowWhiteGlove = $Settings.AllowWhiteGlove
121121
CollectHash = $Settings.CollectHash
122-
hideChangeAccount = $true
123-
hidePrivacy = $Settings.HidePrivacy
124-
hideTerms = $Settings.HideTerms
122+
HideChangeAccount = $true
123+
HidePrivacy = $Settings.HidePrivacy
124+
HideTerms = $Settings.HideTerms
125125
AutoKeyboard = $Settings.AutoKeyboard
126126
Language = $Settings.Languages.value
127127
}

0 commit comments

Comments
 (0)