AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 1165409
Accepted
reinhardS
reinhardS
Asked: 2024-09-18 22:47:41 +0800 CST2024-09-18 22:47:41 +0800 CST 2024-09-18 22:47:41 +0800 CST

如何删除 AAD 中的孤立设备?

  • 772

在 Intune、Entra 中,如何查找和删除主 UPN 被删除的孤立设备?我还需要从 Autopilot 中删除它们。有人有 powershell 脚本吗?

powershell
  • 1 1 个回答
  • 72 Views

1 个回答

  • Voted
  1. Best Answer
    Arko
    2024-09-27T13:18:04+08:002024-09-27T13:18:04+08:00

    您可以使用以下脚本查找和删除没有主 UPN 的孤立设备。首先安装这些模块

    Install-Module -Name AzureAD
    Install-Module Microsoft.Graph -Scope CurrentUser
    Install-Script -Name Get-WindowsAutoPilotInfo -Force
    Install-Module MSOnline
    

    检查此文件

    一旦连接,您应该会看到如下所示的内容,与上面的文档中显示的内容相同。

    在此处输入图片描述

    并按照此文档连接到 Microsoft Graph for Intune

    Connect-MgGraph -Scopes "DeviceManagementManagedDevices.ReadWrite.All"
    

    这将是你的剧本-

    # Thhis will get your devices
    $aadDevices = Get-AzureADDevice
    
    # this will filter devices where the UPN is not assigned
    $orphanedDevices = $aadDevices | Where-Object { $_.DeviceOwnerType -eq 'Personal' -and -not $_.ObjectId }
    
    $orphanedDevices
    

    在此处输入图片描述

    您可以使用 ObjectId 删除这些孤立设备

    $orphanedDevices | ForEach-Object { Remove-AzureADDevice -ObjectId $_.ObjectId }
    

    Intune 的类似方法

    $intuneDevices | ForEach-Object { Remove-MgDeviceManagementManagedDevice -ManagedDeviceId $_.Id }
    

    对于自动驾驶仪

    
    $autopilotDevices = Get-WindowsAutopilotDeviceInfo
    
    $orphanedAutopilotDevices = $autopilotDevices | Where-Object { $_.AssignedUser -eq $null }
    
    $orphanedAutopilotDevices | ForEach-Object { Remove-WindowsAutopilotDevice -DeviceId $_.DeviceId }
    

    您也可以参考 此文档

    • 0

相关问题

  • 资源锁和电源外壳

  • 脚本 - 如何断开远程桌面会话?

  • 如何限制向通讯组发送到外部地址?

  • Powershell对值与数组的作用不同?

  • Windows Powershell Vim 键绑定

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve