SCRIPT: Change Device Ownership the Easy Way!

CLICK HERE for the Github link for the latest version of the code!

In Intune, enrolled devices have a “Ownership” property. This is used to designate, as the term implies, the ownership of a device. It can either be Corporateor Personal.This value is set automatically through the particular enrollment method a device brought into Intune with.

Where does this matter? Good question! You can use them with dynamic device membership rule or maybe even Conditional Access. For example, if you have a mix of personal and corporate drives enrolled in your tenant and you have a particular configuration policy you want to apply to only the devices your org owns, you can create a rule that Ownership attribute the Intune device record has. Nice!

But! But! BUT! What if you have a device that has the ownership set wrong? Easy. Go to Device properties and change the Device Ownership.

BUT, you say, I have A LOTof devices that need their ownership changed! Well, I got you covered with a script to make it nice and easy! All you need is a CSV with Intune Device IDs.

NOTES

  • This script will do a check for supervised status if desired.
  • Required permissions: If you can change the ownership normally in Intune, you should be OK with the required Graph API permissions.
  • Intune Device IDs are required. This script will fail if the ID in the CSV does not have a Intune Device ID match. (It will let you know if a ID doesn’t have a match)
  • Formatting the CSV: The header in row 1 doesn’t matter. The script will display the header value and confirm the value. However, you start device IDs in ROW 2. (Row 1 is skipped in the script)

SCRIPT OVERVIEW

  1. Verifies that the Microsoft.Grpah.Authentication and Microsoft.Graph.DeviceManagement Powershell modules are install.
  2. If needed, imports the Microsoft.Graph.Authentication modules
  3. Asks for the CSV folder and path
  4. Authenticates with the graph API
  5. Loops through each device in the CSV, changing the ownership.

Disclaimer: Use at your own risk, of course. If you have any question, please post a comment below!

(CLICK HERE for the Github link for the latest version of the code!)

Similar Posts