8
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

IntuneのプライマリユーザーをPowerShellで変更する

Last updated at Posted at 2020-01-18

Intuneを運用しているのですが、2020年1月現在GUI上でプライマリユーザーを変更することができません。
これとても困るのです・・・
登録はキッティング時に情シスで対応しているため、情シスメンバーアカウントがプライマリユーザーになってしまい、
端末を誰が利用しているのかが一目でわかりません(台帳では別に管理はしていますが)

AADやIntuneのこの部分です。
2020-01-18_13h39_54.png
2020-01-18_13h41_01.png

PowerShellで変更するには下記のコードを実行します。
実行には、AzureADモジュールが必要です。

install-module azuread
import-module azuread

2020/03/04追記
-Allがない場合取得件数が100件までとなり、
100件以上あった場合エラーとなるため修正

$deviceName = 'PC名'   # configure device name
$newOwner = 'UPN' # login name of the new user
Connect-AzureAD
$device = Get-AzureADDevice -All $true| where { $_.DisplayName -eq $deviceName }
$aduser = Get-AzureADUser -All $true| where { $_.UserPrincipalName -eq $newOwner }
$oldowner = (Get-AzureADDeviceRegisteredOwner -ObjectId $device.ObjectId).ObjectId
"Change owner of device " + $device.DisplayName + " to " + $aduser.DisplayName
Add-AzureADDeviceRegisteredOwner -ObjectId $device.ObjectId -RefObjectId $aduser.ObjectId # add the new owner
Remove-AzureADDeviceRegisteredOwner -ObjectId $device.ObjectId -OwnerId $oldowner         # remove the previous owner
Get-AzureADDeviceRegisteredOwner -ObjectId $device.ObjectId    

このコードを実行すると認証が求められるので、変更権限をもつユーザでログインします。
実行後しばらく待つと、デバイスの所有者情報が変更されます。

ちょっと面倒ですが、登録後に貸与ユーザーを指定して変更しています。

8
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?