在基本移动性和安全性中管理设备访问设置
如果使用基本移动性和安全性,则可能有一些设备无法使用基本移动性和安全性进行管理。 如果是这样,应阻止 Exchange ActiveSync 应用访问基本移动性和安全性不支持的移动设备的 Microsoft 365 电子邮件。 阻止 Exchange ActiveSync 应用访问有助于跨更多设备保护组织信息。
使用以下步骤:
使用 合规性管理员 帐户登录到 Microsoft 365。
在浏览器中,键入: https://compliance.microsoft.com/basicmobilityandsecurity。
转到 “组织设置 ”选项卡。
为不支持的 MDM 设备选择“访问限制”,并确保“允许访问 (设备注册是必需的,) 处于选中状态。
若要了解基本移动性和安全性支持哪些设备,请参阅 基本移动性和安全性的功能。
获取有关基本移动性和安全性托管设备的详细信息
此外,还可以使用 Microsoft Graph PowerShell 获取有关组织中为基本移动性和安全性设置的设备的详细信息。
下面是可用的设备详细信息的细分。
详情 | PowerShell 中要查找的内容 |
---|---|
设备已在基本移动性和安全性中注册。 有关详细信息,请参阅 使用基本移动性和安全性注册移动设备 |
isManaged 参数的值为: True= 已注册设备。 False= 未注册设备。 |
设备符合设备安全策略。 有关详细信息,请参阅 创建设备安全策略 |
isCompliant 参数的值为: True = 设备符合策略。 False = 设备不符合策略。 |
注意
后面的命令和脚本还会返回有关 Microsoft Intune 管理的任何设备的详细信息。
下面是运行以下命令和脚本时需要设置的一些内容:
步骤 1:下载并安装 Microsoft Graph PowerShell SDK
有关这些步骤的详细信息,请参阅 使用 PowerShell 连接到 Microsoft 365。
通过以下步骤安装适用于 Windows PowerShell 的 Microsoft Graph PowerShell SDK:
打开管理员级 PowerShell 命令提示符。
运行以下命令:
Install-Module Microsoft.Graph -Scope AllUsers
如果系统提示安装 NuGet 提供程序,请键入 Y,然后按 Enter 键。
如果系统提示从 PSGallery 安装模块,请键入 Y,然后按 Enter 键。
安装完成后,关闭 PowerShell 命令窗口。
步骤 2:连接到 Microsoft 365 订阅
在 Powershell 窗口中运行以下命令。
Connect-MgGraph -Scopes Device.Read.All, User.Read.All
此时会打开一个弹出窗口,供你登录。 提供管理帐户的凭据并登录。
如果帐户具有必要的权限,可在 Powershell 窗口中看到“欢迎使用 Microsoft Graph!”。
步骤 3:确保能够运行 PowerShell 脚本
注意
如果已设置为运行 PowerShell 脚本,则可以跳过此步骤。
若要运行 Get-GraphUserDeviceComplianceStatus.ps1 脚本,需要启用 PowerShell 脚本的运行。
在 Windows 桌面中,选择“ 开始”,然后键入“Windows PowerShell”。 右键单击“Windows PowerShell”,然后选择“ 以管理员身份运行”。
运行以下命令:
Set-ExecutionPolicy RemoteSigned
出现提示时,键入 Y ,然后按 Enter。
运行 Get-MgDevice cmdlet 以显示组织中所有设备的详细信息
打开适用于 Windows PowerShell Microsoft Azure Active Directory 模块。
运行以下命令:
Get-MgDevice -All -ExpandProperty "registeredOwners" | Where-Object {($_.RegisteredOwners -ne $null) -and ($_.RegisteredOwners.Count -gt 0)}
有关更多示例,请参阅 Get-MgDevice。
运行脚本以获取设备详细信息
首先,将脚本保存到计算机。
将以下文本复制并粘贴到记事本中。
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" }
使用文件扩展名“.ps1”将其另存为 Windows PowerShell 脚本文件。 例如,Get-MgGraphDeviceOwnership.ps1。
注意
该脚本也可在 Github 上下载。
运行脚本以获取单个用户帐户的设备信息
打开 Powershell。
转到保存脚本的文件夹。 例如,如果将其保存到 C:\PS-Scripts,请运行以下命令。
cd C:\PS-Scripts
运行以下命令以标识要为其获取设备详细信息的用户。 此示例获取 的详细信息 user@contoso.com。
$user = Get-MgUser -UserId "user@contoso.com"
运行以下命令以启动脚本。
.\Get-GraphUserDeviceComplianceStatus.ps1 -users $user -Export
该信息将作为 CSV 文件导出到 Windows 桌面。 可以指定 CSV 的文件名和路径。
运行脚本以获取一组用户的设备信息
打开 Powershell。
转到保存脚本的文件夹。 例如,如果将其保存到 C:\PS-Scripts,请运行以下命令。
cd C:\PS-Scripts
运行以下命令以标识要为其获取设备详细信息的组。 此示例获取 FinanceStaff 组中用户的详细信息。
$groupId = Get-MgGroup -Filter "displayName eq 'FinanceStaff'" | Select-Object -ExpandProperty Id $Users = Get-MgGroupMember -GroupId $groupId | Select-Object -ExpandProperty Id | % { Get-MgUser -UserId $_ }
运行以下命令以启动脚本。
.\Get-GraphUserDeviceComplianceStatus.ps1 -User $Users -Export
该信息将作为 CSV 文件导出到 Windows 桌面。 可以使用其他参数来指定 CSV 的文件名和路径。