@@ -2,18 +2,18 @@ function Set-CIPPDefaultAPDeploymentProfile {
22 [CmdletBinding (SupportsShouldProcess = $true )]
33 param (
44 $tenantFilter ,
5- $displayname ,
5+ $displayName ,
66 $description ,
77 $devicenameTemplate ,
88 $allowWhiteGlove ,
99 $CollectHash ,
10- $usertype ,
10+ $userType ,
1111 $DeploymentMode ,
1212 $hideChangeAccount ,
1313 $AssignTo ,
1414 $hidePrivacy ,
1515 $hideTerms ,
16- $Autokeyboard ,
16+ $AutoKeyboard ,
1717 $Headers ,
1818 $Language = ' os-default' ,
1919 $APIName = ' Add Default Enrollment Status Page'
@@ -24,9 +24,9 @@ function Set-CIPPDefaultAPDeploymentProfile {
2424 try {
2525 $ObjBody = [pscustomobject ]@ {
2626 ' @odata.type' = ' #microsoft.graph.azureADWindowsAutopilotDeploymentProfile'
27- ' displayName' = " $ ( $displayname ) "
27+ ' displayName' = " $ ( $displayName ) "
2828 ' description' = " $ ( $description ) "
29- ' deviceNameTemplate' = " $ ( $DeviceNameTemplate ) "
29+ ' deviceNameTemplate' = " $ ( $devicenameTemplate ) "
3030 ' language' = " $ ( $Language ) "
3131 ' enableWhiteGlove' = $ ([bool ]($allowWhiteGlove ))
3232 ' deviceType' = ' windowsPc'
@@ -38,19 +38,19 @@ function Set-CIPPDefaultAPDeploymentProfile {
3838 ' escapeLinkHidden' = $ ([bool ]($hideChangeAccount ))
3939 ' privacySettingsHidden' = $ ([bool ]($hidePrivacy ))
4040 ' eulaHidden' = $ ([bool ]($hideTerms ))
41- ' userType' = " $usertype "
42- ' keyboardSelectionPageSkipped' = $ ([bool ]($Autokeyboard ))
41+ ' userType' = " $userType "
42+ ' keyboardSelectionPageSkipped' = $ ([bool ]($AutoKeyboard ))
4343 }
4444 }
4545 $Body = ConvertTo-Json - InputObject $ObjBody
4646
47- $Profiles = New-GraphGETRequest - uri ' https://graph.microsoft.com/beta/deviceManagement/windowsAutopilotDeploymentProfiles' - tenantid $tenantfilter | Where-Object - Property displayName -EQ $displayname
47+ $Profiles = New-GraphGETRequest - uri ' https://graph.microsoft.com/beta/deviceManagement/windowsAutopilotDeploymentProfiles' - tenantid $tenantFilter | Where-Object - Property displayName -EQ $displayName
4848 if ($Profiles.count -gt 1 ) {
4949 $Profiles | ForEach-Object {
5050 if ($_.id -ne $Profiles [0 ].id) {
5151 if ($PSCmdlet.ShouldProcess ($_.displayName , ' Delete duplicate Autopilot profile' )) {
52- $null = New-GraphPOSTRequest - uri " https://graph.microsoft.com/beta/deviceManagement/windowsAutopilotDeploymentProfiles/$ ( $_.id ) " - tenantid $tenantfilter - type DELETE
53- Write-LogMessage - Headers $User - API $APIName - tenant $ ($tenantfilter ) - message " Deleted duplicate Autopilot profile $ ( $displayname ) " - Sev ' Info'
52+ $null = New-GraphPOSTRequest - uri " https://graph.microsoft.com/beta/deviceManagement/windowsAutopilotDeploymentProfiles/$ ( $_.id ) " - tenantid $tenantFilter - type DELETE
53+ Write-LogMessage - Headers $User - API $APIName - tenant $ ($tenantFilter ) - message " Deleted duplicate Autopilot profile $ ( $displayName ) " - Sev ' Info'
5454 }
5555 }
5656 }
@@ -59,30 +59,30 @@ function Set-CIPPDefaultAPDeploymentProfile {
5959 if (! $Profiles ) {
6060 if ($PSCmdlet.ShouldProcess ($displayName , ' Add Autopilot profile' )) {
6161 $Type = ' Add'
62- $GraphRequest = New-GraphPostRequest - uri ' https://graph.microsoft.com/beta/deviceManagement/windowsAutopilotDeploymentProfiles' - body $body - tenantid $tenantfilter
63- Write-LogMessage - Headers $User - API $APIName - tenant $ ($tenantfilter ) - message " Added Autopilot profile $ ( $displayname ) " - Sev ' Info'
62+ $GraphRequest = New-GraphPostRequest - uri ' https://graph.microsoft.com/beta/deviceManagement/windowsAutopilotDeploymentProfiles' - body $body - tenantid $tenantFilter
63+ Write-LogMessage - Headers $User - API $APIName - tenant $ ($tenantFilter ) - message " Added Autopilot profile $ ( $displayName ) " - Sev ' Info'
6464 }
6565 } else {
6666 $Type = ' Edit'
67- $null = New-GraphPostRequest - uri " https://graph.microsoft.com/beta/deviceManagement/windowsAutopilotDeploymentProfiles/$ ( $Profiles.id ) " - tenantid $tenantfilter - body $body - type PATCH
67+ $null = New-GraphPostRequest - uri " https://graph.microsoft.com/beta/deviceManagement/windowsAutopilotDeploymentProfiles/$ ( $Profiles.id ) " - tenantid $tenantFilter - body $body - type PATCH
6868 $GraphRequest = $Profiles | Select-Object - Last 1
6969 }
7070
7171 if ($AssignTo -eq $true ) {
7272 $AssignBody = ' {"target":{"@odata.type":"#microsoft.graph.allDevicesAssignmentTarget"}}'
73- if ($PSCmdlet.ShouldProcess ($AssignTo , " Assign Autopilot profile $displayname " )) {
73+ if ($PSCmdlet.ShouldProcess ($AssignTo , " Assign Autopilot profile $displayName " )) {
7474 # Get assignments
75- $Assignments = New-GraphGETRequest - uri " https://graph.microsoft.com/beta/deviceManagement/windowsAutopilotDeploymentProfiles/$ ( $GraphRequest.id ) /assignments" - tenantid $tenantfilter
75+ $Assignments = New-GraphGETRequest - uri " https://graph.microsoft.com/beta/deviceManagement/windowsAutopilotDeploymentProfiles/$ ( $GraphRequest.id ) /assignments" - tenantid $tenantFilter
7676 if (! $Assignments ) {
77- $null = New-GraphPOSTRequest - uri " https://graph.microsoft.com/beta/deviceManagement/windowsAutopilotDeploymentProfiles/$ ( $GraphRequest.id ) /assignments" - tenantid $tenantfilter - type POST - body $AssignBody
77+ $null = New-GraphPOSTRequest - uri " https://graph.microsoft.com/beta/deviceManagement/windowsAutopilotDeploymentProfiles/$ ( $GraphRequest.id ) /assignments" - tenantid $tenantFilter - type POST - body $AssignBody
7878 }
79- Write-LogMessage - Headers $User - API $APIName - tenant $ ( $tenantfilter ) - message " Assigned autopilot profile $ ( $Displayname ) to $AssignTo " - Sev ' Info'
79+ Write-LogMessage - Headers $User - API $APIName - tenant $tenantFilter - message " Assigned autopilot profile $ ( $displayName ) to $AssignTo " - Sev ' Info'
8080 }
8181 }
82- " Successfully $ ( $Type ) ed profile for $ ( $tenantfilter ) "
82+ " Successfully $ ( $Type ) ed profile for $tenantFilter "
8383 } catch {
8484 $ErrorMessage = Get-CippException - Exception $_
85- Write-LogMessage - Headers $User - API $APIName - tenant $ ( $tenantfilter ) - message " Failed $ ( $Type ) ing Autopilot Profile $ ( $Displayname ) . Error: $ ( $ErrorMessage.NormalizedError ) " - Sev ' Error' - LogData $ErrorMessage
86- throw " Failed to add profile for $ ( $tenantfilter ) : $ ( $ErrorMessage.NormalizedError ) "
85+ Write-LogMessage - Headers $User - API $APIName - tenant $tenantFilter - message " Failed $ ( $Type ) ing Autopilot Profile $ ( $displayName ) . Error: $ ( $ErrorMessage.NormalizedError ) " - Sev ' Error' - LogData $ErrorMessage
86+ throw " Failed to add profile for $ ( $tenantFilter ) : $ ( $ErrorMessage.NormalizedError ) "
8787 }
8888}
0 commit comments