基本的なモビリティとセキュリティでデバイス アクセス設定を管理する

基本的なモビリティとセキュリティを使用している場合は、基本的なモビリティとセキュリティで管理できないデバイスが存在する可能性があります。 その場合は、基本的なモビリティとセキュリティExchange ActiveSyncサポートされていないモバイル デバイスの Microsoft 365 メールへのアプリ アクセスをブロックする必要があります。 アプリアクセスExchange ActiveSyncブロックすると、より多くのデバイス間でorganization情報をセキュリティで保護できます。

次の手順に従います:

  1. グローバル管理者アカウントで Microsoft 365 にサインインします。

  2. ブラウザーで、「」と入力します https://compliance.microsoft.com/basicmobilityandsecurity

  3. [ 組織の設定 ] タブに移動します。

  4. [ サポートされていない MDM デバイスのアクセス制限] を 選択し 、[アクセスを許可する (デバイス登録が必要)] が 選択されていることを確認します。

基本的なモビリティとセキュリティがサポートするデバイスについては、「基本的なモビリティとセキュリティの機能」を参照してください。

基本的なモビリティとセキュリティの管理対象デバイスに関する詳細を取得する

さらに、Microsoft Graph PowerShell を使用して、基本的なモビリティとセキュリティ用に設定したorganization内のデバイスの詳細を取得できます。

利用可能なデバイスの詳細の内訳は次のとおりです。

詳細 PowerShell で検索する内容
デバイスは基本的なモビリティとセキュリティに登録されています。 詳細については、「基本的なモビリティとセキュリティを使用してモバイル デバイスを登録する」を参照してください。 isManaged パラメーターの値は次のとおりです。
True = デバイスは登録されています。
False = デバイスは登録されていません。
デバイスは、デバイスのセキュリティ ポリシーに準拠しています。 詳細については、「デバイス セキュリティ ポリシーの作成」を参照してください。 isCompliant パラメーターの値は次のとおりです。
True = デバイスはポリシーに準拠しています。
False = デバイスがポリシーに準拠していません。

PowerShell パラメーターを基本的なモビリティとセキュリティします。

注:

次のコマンドとスクリプトは、Microsoft Intuneによって管理されるすべてのデバイスに関する詳細も返します。

次のコマンドとスクリプトを実行するために設定する必要があるいくつかの事項を次に示します。

手順 1: Microsoft Graph PowerShell SDK をダウンロードしてインストールする

これらの手順の詳細については、「 PowerShell を使用して Microsoft 365 に接続する」を参照してください。

  1. 次の手順で Microsoft Graph PowerShell SDK for Windows PowerShellをインストールします。

    1. 管理者レベルの PowerShell コマンド プロンプトを開きます。

    2. 次のコマンドを実行します。

      Install-Module Microsoft.Graph -Scope AllUsers
      
    3. NuGet プロバイダーをインストールするようにメッセージが表示されたら、「Y」と入力し、ENTER を押します。

    4. PSGallery からモジュールをインストールするようにメッセージが表示されたら、「Y」と入力し、Enter を押します。

    5. インストール後、PowerShell コマンド ウィンドウを閉じます。

手順 2: Microsoft 365 サブスクリプションに接続する

  1. Powershell ウィンドウで、次のコマンドを実行します。

    Connect-MgGraph -Scopes Device.Read.All, User.Read.All
    
  2. サインインするためのポップアップが開きます。 管理アカウントの資格情報を入力し、ログインします。

  3. アカウントに必要なアクセス許可がある場合は、Powershell ウィンドウに 「Microsoft Graph へようこそ」と表示されます。

手順 3: PowerShell スクリプトを実行できることを確認する

注:

PowerShell スクリプトを実行するように既に設定されている場合は、この手順をスキップできます。

Get-GraphUserDeviceComplianceStatus.ps1 スクリプトを実行するには、PowerShell スクリプトの実行を有効にする必要があります。

  1. Windows デスクトップから [スタート] を選択し、「Windows PowerShell」と入力します。 Windows PowerShellを右クリックし、[管理者として実行] を選択します。

  2. 次のコマンドを実行します。

    Set-ExecutionPolicy RemoteSigned
    
  3. プロンプトが表示されたら、「Y」と入力し、Enter キーを押します。

Get-MgDevice コマンドレットを実行して、organization内のすべてのデバイスの詳細を表示します。

  1. Windows PowerShellのMicrosoft Azure Active Directory モジュールを開きます。

  2. 次のコマンドを実行します。

    Get-MgDevice -All -ExpandProperty "registeredOwners" | Where-Object {($_.RegisteredOwners -ne $null) -and ($_.RegisteredOwners.Count -gt 0)}
    

その他の例については、「 Get-MgDevice」を参照してください。

スクリプトを実行してデバイスの詳細情報を取得する

最初に、コンピューターにスクリプトを保存します。

  1. 次のテキストをメモ帳にコピーして貼り付けます。

        param (
     	[Parameter(Mandatory = $false)]
     	[PSObject[]]$users = @(),
     	[Parameter(Mandatory = $false)]
     	[Switch]$export,
     	[Parameter(Mandatory = $false)]
     	[String]$exportFileName = "UserDeviceOwnership_" + (Get-Date -Format "yyMMdd_HHMMss") + ".csv",
     	[Parameter(Mandatory = $false)]
     	[String]$exportPath = [Environment]::GetFolderPath("Desktop")
     )
    
     #Clearing the screen
     Clear-Host
    
     #Preparing the output object
     $deviceOwnership = @()
    
    
     if ($users.Count -eq 0) {
     	Write-Output "No user has been provided, gathering data for all devices in the tenant"
     	#Getting all Devices and their registered owners
     	$devices = Get-MgDevice -All -Property * -ExpandProperty registeredOwners
    
     	#For each device which has a registered owner, extract the device data and the registered owner data
     	foreach ($device in $devices) {
     		$DeviceOwners = $device | Select-Object -ExpandProperty 'RegisteredOwners'
     		#Checking if the DeviceOwners Object is empty
     		if ($DeviceOwners -ne $null) {
     			foreach ($DeviceOwner in $DeviceOwners) {
     				$OwnerDictionary = $DeviceOwner.AdditionalProperties
     				$OwnerDisplayName = $OwnerDictionary.Item('displayName')
     				$OwnerUPN = $OwnerDictionary.Item('userPrincipalName')
     				$OwnerID = $deviceOwner.Id
     				$deviceOwnership += [PSCustomObject]@{
     					DeviceDisplayName             = $device.DisplayName
     					DeviceId                      = $device.DeviceId
     					DeviceOSType                  = $device.OperatingSystem
     					DeviceOSVersion               = $device.OperatingSystemVersion
     					DeviceTrustLevel              = $device.TrustType
     					DeviceIsCompliant             = $device.IsCompliant
     					DeviceIsManaged               = $device.IsManaged
     					DeviceObjectId                = $device.Id
     					DeviceOwnerID                 = $OwnerID
     					DeviceOwnerDisplayName        = $OwnerDisplayName
     					DeviceOwnerUPN                = $OwnerUPN
     					ApproximateLastLogonTimestamp = $device.ApproximateLastSignInDateTime
     				}
     			}
     		}
    
     	}
     }
    
     else {
     	#Checking that userid is present in the users object
     	Write-Output "List of users has been provided, gathering data for all devices owned by the provided users"
     	foreach ($user in $users) {
     		$devices = Get-MgUserOwnedDevice -UserId $user.Id -Property *
     		foreach ($device in $devices) {
     			$DeviceHashTable = $device.AdditionalProperties
     			$deviceOwnership += [PSCustomObject]@{
     				DeviceId                      = $DeviceHashTable.Item('deviceId')
     				DeviceOSType                  = $DeviceHashTable.Item('operatingSystem')
     				DeviceOSVersion               = $DeviceHashTable.Item('operatingSystemVersion') 
     				DeviceTrustLevel              = $DeviceHashTable.Item('trustType')
     				DeviceDisplayName             = $DeviceHashTable.Item('displayName')
     				DeviceIsCompliant             = $DeviceHashTable.Item('isCompliant')
     				DeviceIsManaged               = $DeviceHashTable.Item('isManaged')
     				DeviceObjectId                = $device.Id
     				DeviceOwnerUPN                = $user.UserPrincipalName
     				DeviceOwnerID                 = $user.Id
     				DeviceOwnerDisplayName        = $user.DisplayName
     				ApproximateLastLogonTimestamp = $DeviceHashTable.Item('approximateLastSignInDateTime')
     			}
     		}
     	}
    
     }
    
     $deviceOwnership
    
     if ($export) {
     	$exportFile = Join-Path -Path $exportPath -ChildPath $exportFileName
     	$deviceOwnership | Export-Csv -Path $exportFile -NoTypeInformation
     	Write-Output "Data has been exported to $exportFile"
     }
    
  2. ファイル拡張子 ".ps1" を使用して、Windows PowerShell スクリプト ファイルとして保存します。 たとえば、Get-MgGraphDeviceOwnership.ps1。

    注:

    スクリプトは Github でダウンロードすることもできます。

スクリプトを実行して、単一のユーザー アカウントのデバイス情報を取得する

  1. Powershell を開きます。

  2. スクリプトを保存したフォルダーに移動します。 たとえば、C:\PS-Scripts に保存した場合は、次のコマンドを実行します。

    cd C:\PS-Scripts
    
  3. 次のコマンドを実行して、デバイスの詳細情報を取得するユーザーを特定します。 この例では、 の詳細を取得します user@contoso.com。

    $user = Get-MgUser -UserId "user@contoso.com"
    
  4. 次のコマンドを実行して、スクリプトを開始します。

    .\Get-GraphUserDeviceComplianceStatus.ps1 -users $user -Export
    

この情報は、Windows デスクトップに CSV ファイルとしてエクスポートされます。 CSV のファイル名とパスを指定できます。

スクリプトを実行して、ユーザーのグループのデバイス情報を取得する

  1. Powershell を開きます。

  2. スクリプトを保存したフォルダーに移動します。 たとえば、C:\PS-Scripts に保存した場合は、次のコマンドを実行します。

    cd C:\PS-Scripts
    
  3. 次のコマンドを実行して、デバイスの詳細情報を取得するグループを特定します。 この例では、FinanceStaff グループのユーザーの詳細情報を取得します。

    $groupId = Get-MgGroup -Filter "displayName eq 'FinanceStaff'" | Select-Object -ExpandProperty Id
    $Users = Get-MgGroupMember -GroupId $groupId | Select-Object -ExpandProperty Id | % { Get-MgUser -UserId $_ }
    
  4. 次のコマンドを実行して、スクリプトを開始します。

    .\Get-GraphUserDeviceComplianceStatus.ps1 -User $Users -Export
    

この情報は、Windows デスクトップに CSV ファイルとしてエクスポートされます。 追加のパラメーターを使用して、ファイル名と CSV のパスを指定することができます。

Microsoft Connect は廃止されました

基本的なモビリティとセキュリティの概要

MSOnline コマンドレットと AzureAD コマンドレットの廃止のお知らせ

Get-MgUser

Get-MgDevice

Get-MgUserOwnedDevice