Intune: Rename managed iOS device with Graph
23. Juli 2018 Hinterlasse einen Kommentar
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.
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.
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.
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.
We can prove the initiation of the rename process with the Intune portal.
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.