Skip to content

Script for Updating Device Ownership in Microsoft Graph

Device Ownership Update Script for Microsoft Graph

Section titled “Device Ownership Update Script for Microsoft Graph”

This PowerShell script connects to Microsoft Graph with appropriate permissions and automates the process of updating device ownership from personal to company for managed devices.


FunctionDescriptionBusiness Value
AuthenticationConnects to Microsoft Graph with DeviceManagementManagedDevices.ReadWrite.All scopeSecure API access to device management data
Device FilteringRetrieves macOS and Windows devices owned by personal usersTargeted updates for specific device types
Ownership UpdateChanges ownership type from “personal” to “company”Ensures proper device classification and compliance

The script establishes a secure connection using Connect-MgGraph with the required permissions scope for device management operations.

  • Filters devices by operating system (macOS and Windows)
  • Identifies devices with “personal” ownership type
  • Creates a targeted list for ownership updates
  • Iterates through filtered devices
  • Updates ownership type using Update-MgDeviceManagementManagedDevice cmdlet
  • Changes classification from “personal” to “company”

Terminal window
Connect-MgGraph -Scopes "DeviceManagementManagedDevices.ReadWrite.All"
Get-MgDeviceManagementManagedDevice |
Where-Object {($_.OperatingSystem -EQ "macOS") -or ($_.OperatingSystem -EQ "Windows")}|
Where-Object ManagedDeviceOwnerType -EQ "personal" |
ForEach-Object {Update-MgDeviceManagementManagedDevice -ManagedDeviceId $_.Id -ManagedDeviceOwnerType "company" }

Ideal for: Organizations managing mixed device environments with Microsoft Intune

Use Cases:

  • Bulk device ownership corrections
  • Compliance automation
  • Device lifecycle management
  • Security policy enforcement

Important: This script requires appropriate Microsoft Graph permissions and should be tested in a non-production environment first.