微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

无法删除自动驾驶仪配置文件,因为它在 Intune 中仍处于活动状态但已在 Intune 中删除

如何解决无法删除自动驾驶仪配置文件,因为它在 Intune 中仍处于活动状态但已在 Intune 中删除

我正在尝试删除在 Intune 中删除的设备的所有自动驾驶仪配置文件。对于某些设备,这会产生错误。我尝试在界面中手动删除自动驾驶仪配置文件,但也出现错误deletion Failed. Please delete the associated Intune device before deleting this Autopilot device record.

经过一些谷歌搜索后,我发现他们是一种解决方法,可以删除 Microsoft Store 中用于商业 Web 界面的设备。这很有效(在结果可见之前花了一些时间)。我想使用 powershell 自动执行此操作。所以我去谷歌搜索 cmdlet,但我只能在 powershellgallery 上找到 MSStore。但这不包含 remove-msstore-device 函数。有没有人知道一个 cmd-let 来实现这个或不同的解决方法

我用来删除自动驾驶仪配置文件代码

$admin = Read-host "Please enter your administrator account"
connect-azureAD -Accountid $admin
Connect-MSGraph -AdminConsent

Try {
    $timestamp = Read-Host "Please enter a date in the past (yyyy/MM/dd)" -ErrorAction Stop
    $date_time = [datetime]::ParseExact($timestamp,"yyyy/MM/dd",$null) 
} Catch {
    Write-host "Wrong Syntax for the date! Please try again ..." -ForegroundColor Red
}


$AutopilotDevices = Get-AutopilotDevice | select serialNumber,model,deploymentProfileAssignedDateTime,deploymentProfileAssignmentStatus,Id
$ExtraAutopilotDevicesToDelete = $AutopilotDevices | ? {
    ($_.serialnumber -notin $IntuneDevices.serialNumber) -and`
    ($_.deploymentProfileAssignedDateTime -lt $date_time) -and`
    ($_.deploymentProfileAssignmentStatus -ne "notAssigned")
} | sort-object deploymentProfileAssignedDateTime

Write-Host "There are $($AutopilotDevices.Count) Auto-Pilot devices detected ..." -ForegroundColor Yellow
Write-Host "There are $($IntuneDevices.count) Intune devices detected ..." -ForegroundColor Yellow
Write-Host "There is a list of $($ExtraAutopilotDevicesToDelete.Count) Auto-Pilot devices which can be removed ..." -ForegroundColor Yellow
Read-Host "Hit Enter to see the list of devices ..."

$ExtraAutopilotDevicesToDelete | ft

Write-Host "Are you sure you want to delete the $($ExtraAutopilotDevicesToDelete.Count) Auto-Pilot devices listed above?" -ForegroundColor Red
Read-host "Press enter to continue... (CTRL + C to abort)"

$ExtraAutopilotDevicesToDelete | % {
    Write-Host "Deleting device with serial number $($_.serialnumber)..." -ForegroundColor magenta
    Get-AutopilotDevice -serial $_.serialnumber
    Remove-AutopilotDevice -id $_.id
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。