# MrNetTek # eddiejackson.net/blog # 1/17/2020 # free for public use # free to claim as your own clear-host $user = 'username@domain.com' $computer = 'computername' $userSearch = $user.SubString(0,1) $newUser = Get-AzureADUser -SearchString $userSearch | where { $_.UserPrincipalName -eq $user } | Select -ExpandProperty ObjectId $device = Get-AzureADDevice | where { $_.DisplayName -eq $computer } $oldOwner = (Get-AzureADDeviceRegisteredOwner -ObjectId $device.ObjectId).ObjectId Add-AzureADDeviceRegisteredOwner -ObjectId $device.ObjectId -RefObjectId $newUser Remove-AzureADDeviceRegisteredOwner -ObjectId $device.ObjectId -RefObjectId $oldOwner Get-AzureADDeviceRegisteredOwner -ObjectId $device.ObjectId
Notes
Get-AzureADUser
Get-AzureADDevice
Get-AzureADDeviceRegisteredOwner
Add-AzureADDeviceRegisteredOwner
Remove-AzureADDeviceRegisteredOwner
Get-AzureADDeviceRegisteredOwner
Substring method
tags: PowerShell, Azure registered user, change registered user in Azure Intune, MrNetTek