Intune icon indicating copy to clipboard operation
Intune copied to clipboard

Set-AutoPilotDeviceAssignedUser still expected to work?

Open MichaelReiserSAP opened this issue 1 year ago • 3 comments

Hi, is the Set-AutoPilotDeviceAssignedUser function still expected to work? I'm trying to use in but can't make it work.

Set-AutoPilotDeviceAssignedUser : System.Net.Http.HttpRequestException: 400 Bad Request {"error":{"code":"BadRequest","message":"{\r\n "_version": 3,\r\n "Message": "An error has occurred - Operation ID (for customer support): 00000000-0000-0000-0000-000000000000 - Activity ID: 105e0390-e8ee-47cf-86c6-cfb576279131 - Url: https://fef.amsub0202.manage.microsoft.com/DeviceEnrollmentFE/StatelessDeviceEnrollmentFEService/deviceManagement/windowsAutopilotDeviceIdentities('d565e906-babd-494e-baab-85ce1a5583 17')/microsoft.management.services.api.assignUserToDevice?api-version=5023-06-28",\r\n "CustomApiErrorPhrase": "",\r\n "RetryAfter": null,\r\n "ErrorSourceService": "",\r\n "HttpHeaders": "{}"\r\n}","innerError":{"date":"2024-02-07T07:04:41","request-id":"105e0390-e8ee-47cf-86c6-cfb576279131","client-request-id":"105e0390-e8ee-47cf-86c6-cfb576279131"}}} At C:\Users\D053249\SAP SE\IES EMEA - Intune\Scripts\AssignUserToDevice\AssignUserToDevice.ps1:204 char:1

  • Set-AutoPilotDeviceAssignedUser -userPrincipalName "xxxxxxxxxx ...
  •   + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
      + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Set-AutoPilotDeviceAssignedUser
    
    

MichaelReiserSAP avatar Feb 07 '24 07:02 MichaelReiserSAP

TIP: Working way is to use "https://graph.microsoft.com/$graphApiVersion/$Resource/$id/UpdateDeviceProperties" as I do in my Set-AutopilotDevice function (https://www.powershellgallery.com/packages/IntuneStuff module)

ztrhgf avatar Feb 07 '24 07:02 ztrhgf

TIP: Working way is to use "https://graph.microsoft.com/$graphApiVersion/$Resource/$id/UpdateDeviceProperties" as I do in my Set-AutopilotDevice function (https://www.powershellgallery.com/packages/IntuneStuff module)

I'll check this out today!

MichaelReiserSAP avatar Feb 07 '24 07:02 MichaelReiserSAP

Btw use it like: Set-AutopilotDevice -id <autopilotDeviceId> -userPrincipalName "[email protected]" -addressableUserName "John Doe"

ztrhgf avatar Feb 07 '24 08:02 ztrhgf