You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过Azure AD设备名称(如DESKTOP-IMMKAOT)查询设备序列号

通过PowerShell关联Azure AD设备名称与AutoPilot序列号

可以通过Microsoft Graph PowerShell模块实现批量查询,具体步骤如下:

1. 准备工作:安装并导入所需模块

首先确保安装了Microsoft Graph设备管理模块:

Install-Module Microsoft.Graph.DeviceManagement -Force -AllowClobber
Import-Module Microsoft.Graph.DeviceManagement

2. 连接到Microsoft Graph

使用具备对应权限的账号登录,需要的权限包括DeviceManagementServiceConfig.Read.All和Directory.Read.All:

Connect-MgGraph -Scopes "DeviceManagementServiceConfig.Read.All", "Directory.Read.All"

3. 获取AutoPilot设备与Azure AD设备数据

分别拉取AutoPilot设备(含序列号和Azure AD设备ID)以及Azure AD设备(含设备名称和ID):

# 获取所有AutoPilot设备信息
$autoPilotDevices = Get-MgDeviceManagementWindowsAutopilotDeviceIdentity -All | Select-Object SerialNumber, AzureAdDeviceId, DeviceName

# 获取所有DESKTOP-xxx开头的Azure AD设备
$aadDevices = Get-MgDevice -All | Where-Object DisplayName -like "DESKTOP-*" | Select-Object DisplayName, Id

4. 关联数据并输出结果

通过Azure AD设备ID匹配两个数据集,生成包含设备名称和对应序列号的结果:

$matchedDevices = foreach ($aadDevice in $aadDevices) {
    $apMatch = $autoPilotDevices | Where-Object { $_.AzureAdDeviceId -eq $aadDevice.Id }
    if ($apMatch) {
        [PSCustomObject]@{
            AzureAD_Device_Name = $aadDevice.DisplayName
            Serial_Number       = $apMatch.SerialNumber
            AutoPilot_Device_Name = $apMatch.DeviceName
        }
    }
}

# 控制台输出结果
$matchedDevices | Format-Table -AutoSize

# 导出为CSV文件(方便批量查看)
$matchedDevices | Export-Csv -Path "AAD_Device_Serial_Map.csv" -NoTypeInformation -Encoding UTF8

注意事项

  • 若不需要筛选DESKTOP-xxx设备,可去掉Where-Object DisplayName -like "DESKTOP-*"条件,获取所有Azure AD设备的关联数据
  • 确保执行脚本的账号拥有足够权限:需在Azure AD中分配Cloud Device Administrator或类似角色,确保能读取AutoPilot和Azure AD设备信息
  • 旧版AzureAD模块也可实现类似逻辑,但Microsoft已弃用该模块,推荐使用Microsoft Graph模块

内容的提问来源于stack exchange,提问作者David Borough

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.17 09:15:39