question

Mikaelstergren-5182 avatar image
0 Votes"
Mikaelstergren-5182 asked Crystal-MSFT commented

Adding serialnumbers using New-MgDeviceManagementImportedDeviceIdentity - error

I am trying to use the cmd New-MgDeviceManagementImportedDeviceIdentity to insert new serialnumbers from our assetDB.
connect-mggraph works fine, using certificate and appID.

My testing example (serial is fakeserial, but valid):

 $NewID = New-Object Microsoft.Graph.PowerShell.Models.MicrosoftGraphImportedDeviceIdentity
 $NewID.Description = "A Description"
 $NewID.ImportedDeviceIdentifier = "07C200200007"
 $NewID.ImportedDeviceIdentityType = "serialNumber"
    
 I then run the command
 New-MgDeviceManagementImportedDeviceIdentity -BodyParameter $NewID

The error i receive looks like this.
New-MgDeviceManagementImportedDeviceIdentity : No OData route exists that match template ~/singleton/navigation with http verb POST for request /DeviceEnrollmentFE_2204/StatelessDeviceEnrollmentFESe
rvice/deviceManagement/importedDeviceIdentities.

I posted a ticket about this here: 147
I then tried the suggestion using :


  $ImportedDeviceIdentities = @{
     "@odata.type" = "#microsoft.graph.importedDeviceIdentity"
     Description = "A Description"
     ImportedDeviceIdentifier = "07C200200007"
     ImportedDeviceIdentityType = "serialNumber"
     # Add more details.
   } 
    
    Import-MgDeviceManagementImportedDeviceIdentityList -ImportedDeviceIdentities $ImportedDeviceIdentities -OverwriteImportedDeviceIdentities:$false

But this generated a new error:
Import-MgDeviceManagementImportedDeviceIdentityList : Unable to cast object of type 'Microsoft.Graph.PowerShell.Runtime.Json.JsonObject' to type 'Microsoft.Graph.PowerShell.Runtime.Json.JsonArray'.
At line:11 char:1
+ Import-MgDeviceManagementImportedDeviceIdentityList -ImportedDeviceId ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Import-MgDevice..._ImportExpanded], InvalidCastException
+ FullyQualifiedErrorId : Microsoft.Graph.PowerShell.Cmdlets.ImportMgDeviceManagementImportedDeviceIdentityList_ImportExpanded






mem-intune-enrollment
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

Crystal-MSFT avatar image
0 Votes"
Crystal-MSFT answered Crystal-MSFT commented

@Mikaelstergren-5182, From your description, we are using "New-MgDeviceManagementImportedDeviceIdentity" to import device identities. But it is failed.

Maybe you can try the similar command as below to see if it works:

 Install-Module Microsoft.Graph.DeviceManagement.Enrolment 
 Import-Module Microsoft.Graph.DeviceManagement.Enrolment
 Connect-MgGraph  
 New-MgDeviceManagementImportedWindowAutopilotDeviceIdentity -serialnumber "xxxxxxxx"

Hope it can help.


If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@Mikaelstergren-5182,Hope things are going well. I am writing to see if the above commands can work. If there's any update, feel free to let us know.

0 Votes 0 ·