File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -58,11 +58,12 @@ function Set-CIPPDefaultAPDeploymentProfile {
5858 }
5959 if (! $Profiles ) {
6060 if ($PSCmdlet.ShouldProcess ($displayName , ' Add Autopilot profile' )) {
61+ $Type = ' Add'
6162 $GraphRequest = New-GraphPostRequest - uri ' https://graph.microsoft.com/beta/deviceManagement/windowsAutopilotDeploymentProfiles' - body $body - tenantid $tenantfilter
6263 Write-LogMessage - user $User - API $APIName - tenant $ ($tenantfilter ) - message " Added Autopilot profile $ ( $displayname ) " - Sev ' Info'
6364 }
6465 } else {
65- # patch the profile
66+ $Type = ' Edit '
6667 $null = New-GraphPostRequest - uri " https://graph.microsoft.com/beta/deviceManagement/windowsAutopilotDeploymentProfiles/$ ( $Profiles.id ) " - tenantid $tenantfilter - body $body - type PATCH
6768 $GraphRequest = $Profiles | Select-Object - Last 1
6869 }
@@ -78,10 +79,10 @@ function Set-CIPPDefaultAPDeploymentProfile {
7879 Write-LogMessage - user $User - API $APIName - tenant $ ($tenantfilter ) - message " Assigned autopilot profile $ ( $Displayname ) to $AssignTo " - Sev ' Info'
7980 }
8081 }
81- " Successfully added profile for $ ( $tenantfilter ) "
82+ " Successfully $ ( $Type ) ed profile for $ ( $tenantfilter ) "
8283 } catch {
8384 $ErrorMessage = Get-CippException - Exception $_
84- Write-LogMessage - user $User - API $APIName - tenant $ ($tenantfilter ) - message " Failed adding Autopilot Profile $ ( $Displayname ) . Error: $ ( $ErrorMessage.NormalizedError ) " - Sev ' Error' - LogData $ErrorMessage
85+ Write-LogMessage - user $User - API $APIName - tenant $ ($tenantfilter ) - message " Failed $ ( $Type ) ing Autopilot Profile $ ( $Displayname ) . Error: $ ( $ErrorMessage.NormalizedError ) " - Sev ' Error' - LogData $ErrorMessage
8586 throw " Failed to add profile for $ ( $tenantfilter ) : $ ( $ErrorMessage.NormalizedError ) "
8687 }
8788}
You can’t perform that action at this time.
0 commit comments