在 基本移动性和安全性 中管理设备访问设置

如果使用的是基本移动性和安全性,则可能存在无法使用 基本移动性和安全性 管理的设备。 如果是这样,应阻止Exchange ActiveSync应用访问基本移动性和安全性不支持的移动设备的 Microsoft 365 电子邮件。 阻止Exchange ActiveSync应用访问有助于跨更多设备保护组织信息。

使用以下步骤:

  1. 使用全局管理员帐户登录到 Microsoft 365。

  2. 在浏览器中,键入: https://compliance.microsoft.com/basicmobilityandsecurity

  3. 转到 “组织设置 ”选项卡。

  4. 为不支持的 MDM 设备选择“访问限制”,并确保“允许访问 (设备注册是必需的,) 处于选中状态。

若要了解基本移动性和安全性支持哪些设备,请参阅基本移动性和安全性的功能

获取有关基本移动性和安全性托管设备的详细信息

此外,可以使用 Microsoft Graph PowerShell 获取组织中为基本移动性和安全性设置的设备的详细信息。

下面是可用的设备详细信息的细分。

详情 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 cmdlet 以显示组织中所有设备的详细信息

  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
    

该信息将作为 CSV 文件导出到 Windows 桌面。 可以指定 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
    

该信息将作为 CSV 文件导出到 Windows 桌面。 可以使用其他参数来指定 CSV 的文件名和路径。

Microsoft Connect 已停用

基本移动性和安全性概览

MSOnline 和 AzureAD cmdlet 的停用公告

Get-MgUser

Get-MgDevice

Get-MgUserOwnedDevice