I am looking to change the Device Name and Friendly Name of iOS devices to a different value via the Rest-API. I am able to change the Friendly Name like this:
$requestHeaders = @{
'Accept' = 'application/json'
'Authorization' = $auth
'aw-tenant-code' = $wsoApiKey
}
$body = @{
'DeviceFriendlyName' = $WsoDeviceName
}
$body = ConvertTo-Json $body
$uri = $wsoApiUri + $WsoDevice.Id.Value
Invoke-RestMethod -Uri $uri -ContentType "application/json; charset=utf-8" -Headers $requestHeaders -Body $body -Method Put
But I can't seem to find the correct attribute to change the Device Name, neither in the local API help (at server.local/api/help), nor in vmwares documentation. Sending a PUT-request to change the DeviceName or DeviceReportedName shows no changes whatsoever. The code for that looked like:
$body = @{
'DeviceName' = $WsoDeviceName
}
I am aware of the possibility to set the Friendly Name as Device Name via the web interface. Maybe there is a way to activate that option via API, that I did not find? In this case it would get the job done.
Would be glad, if someone could point me in the right direction.
Best regards
Holewasch
I was able to accomplish this using a custom MDM command. In the example below, I specifically use the POST /devices/commands
method while searching by a serial number for the device.
$MdmCommandXml = [xml]@'
<dict>
<key>RequestType</key>
<string>Settings</string>
<key>Settings</key>
<array>
<dict>
<key>DeviceName</key>
<string></string>
<key>Item</key>
<string>DeviceName</string>
</dict>
</array>
</dict>
'@
$Auth = ""
$WsoApiKey = ""
$BaseUrl = "https://as<yourhostnumber>.awmdm.com/API/mdm"
$SerialNumber = ""
$Uri = "${BaseUrl}/devices/commands?command=CustomMdmCommand&searchBy=Serialnumber&id=${SerialNumber}"
$NewDeviceName = "NewDeviceName"
$MdmCommandXml.SelectSingleNode('//key[.="DeviceName"]/following-sibling::*[1]').InnerXml = $NewDeviceName
$RequestHeaders = @{
'Accept' = 'application/json'
'Authorization' = $Auth
'aw-tenant-code' = $WsoApiKey
}
$Body = @{
'CommandXml' = $MdmCommandXml.OuterXml
}
$Body = ConvertTo-Json $Body
Invoke-RestMethod -Uri $Uri -ContentType "application/json; charset=utf-8" -Headers $RequestHeaders -Body $Body -Method Post