Intune: Rename managed iOS device with Graph

I got the question from the customer about how to rename iOS devices in Intune. We discovered that a rename operation is possible if the device is:

  • Company owned
  • Supervised

In this case there’s a „Rename“ button in the device property view.

Intune-Device-Rename-1

The rename process is straightforward and a short time after resyncing the device, we can see the new name on the device itself and in the Intune portal.

Intune-Device-Rename-2

The next challenge started with the question „Can we do this by Powershell?“.

Sure, why not, but how?

First step in getting a picture if this can work, is to use the network analysis (F12) in the browser during the rename operation in the portal.

 

Intune-Device-Rename-3

It gets clear that there is a „POST“ method „/setDeviceName“ which triggers the device rename. There is also a JSON file uploaded during POST that contains the target device name. It contains just on line:

{"deviceName":"Wolfgang's iPad NewName"}

So next step is to visit the Intune Graph Sample library on Github https://github.com/microsoftgraph/powershell-intune-samples. After a little bit of searching and trying we found this example DeviceConfiguration_Import_FromJSON.ps1„.

It seems that the framework of this script can provide the features we need. We have to edit just one line:

line 174 old: $DCP_resource = "deviceManagement/deviceConfigurations"
line 174 new: $DCP_resource = "deviceManagement/managedDevices('c09c5e68-1503-4f22-a4f2-c0724706efee')/setDeviceName"

It’s not so comfortable till now but its just a feasability study at the moment 🙂 We have to include the Intune device ID in the POST method. During runtime we have to provide the administrative context and the name of the JSON file.

Intune-Device-Rename-5

We can prove the initiation of the rename process with the Intune portal.

Intune-Device-Rename-4

The device renames itself after the next policy interval cycle and the Intune portal reflects the new name shortly after that.

Thanks @davefalkus for the sample Intune Graph library.

 

 

Advertisements

Kommentar verfassen

Trage deine Daten unten ein oder klicke ein Icon um dich einzuloggen:

WordPress.com-Logo

Du kommentierst mit Deinem WordPress.com-Konto. Abmelden /  Ändern )

Google+ Foto

Du kommentierst mit Deinem Google+-Konto. Abmelden /  Ändern )

Twitter-Bild

Du kommentierst mit Deinem Twitter-Konto. Abmelden /  Ändern )

Facebook-Foto

Du kommentierst mit Deinem Facebook-Konto. Abmelden /  Ändern )

Verbinde mit %s

%d Bloggern gefällt das: