microsoftgraph / microsoftgraph/msgraph-sdk-powershell
Rename MgGraph device? I have a tenant with a bunch of devices named "iPhone", want to make them distinct / unique
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 898
- Forks
- 230
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 31
Description
I have many M365 tenants with multiple MgGraph devices named with non-identifying generic names like "iPhone" etc.
I want to make them distinct / unique. There doesn't seem to be any way, either as the admin nor the end user in the https://mysignins.microsoft.com/security-info page, to make these devices more descriptive.
This is not just an inconvenience—it's a legitimate security concern. For example, in the case of a phishing attack or breach, where an attacker is able to register an additional MFA device, how can we tell which is the "real" device and which is the malicious device that should be removed?
I created this small test function Rename-Device to rename a Device using the Graph API Update device method:
function Rename-Device {
param (
[Parameter(Mandatory = $false)]
[string]$Id,
[Parameter(Mandatory = $false)]
[string]$deviceId,
[Parameter(Mandatory = $true)]
[string]$Name
)
if ((-not $deviceId) -and (-not $Id)) {
Write-Error '-deviceId or -Id is required' -ErrorAction Stop
}
if ($Id) {
$uri = "https://graph.microsoft.com/beta/devices/$Id"
$body = @{ displayName = $Name } | ConvertTo-Json
} else {
$uri = "https://graph.microsoft.com/beta/devices"
$body = @{
displayName = $Name
deviceId = $deviceId
} | ConvertTo-Json
}
$response = Invoke-MgGraphRequest -Method PATCH -Uri $uri -Body $body -ContentType "application/json"
return $response
}
However, it returns an error Properties other than ExtendedAttribute1..15 can be modified only on windows devices:
PS /Users/luke> Rename-Device -Id be826cc0-d65e-45bd-aed9-4f8de127e3ee -Name 'Test Device 1'
Invoke-MgGraphRequest: /Users/luke/.config/powershell/Microsoft.PowerShell_profile.ps1:160
Line |
160 | … $response = Invoke-MgGraphRequest -Method PATCH -Uri $uri -Body $body …
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| PATCH https://graph.microsoft.com/beta/devices/be826cc0-d65e-45bd-aed9-4f8de127e3ee HTTP/1.1 400 Bad Request
| Cache-Control: no-cache Transfer-Encoding: chunked Vary: Accept-Encoding Strict-Transport-Security:
| max-age=31536000 request-id: 7bd23c2a-7468-480f-9e7f-3cda681525a6 client-request-id:
| 4b2f2d01-9a9e-436a-9a12-67a4353848a7 x-ms-ags-diagnostic: {"ServerInfo":{"DataCenter":"East
| US","Slice":"E","Ring":"5","ScaleUnit":"006","RoleInstance":"BL6PEPF0001D27A"}} x-ms-resource-unit: 1 Date:
| Mon, 20 Nov 2023 13:05:40 GMT Content-Type: application/json Content-Encoding: gzip
| {"error":{"code":"Request_BadRequest","message":"Properties other than ExtendedAttribute1..15 can be modified
| only on windows
| devices.","innerError":{"date":"2023-11-20T13:05:41","request-id":"7bd23c2a-7468-480f-9e7f-3cda681525a6","client-request-id":"4b2f2d01-9a9e-436a-9a12-67a4353848a7"}}}
Is there any method for assigning a proper name to a non-windows MgDevice please?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the provided Rename-Device reproduction and the linked Microsoft Graph Update device documentation, focusing on the non-Windows PATCH behavior and error. Determine whether the PowerShell SDK can support assigning a name to non-Windows MgDevice objects; completion should establish a supported method or clearly document the limitation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- powershell
- Domain
- api
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100