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

Intune脚本执行正常但平台显示失败,报错12180求解决

问题:Intune脚本执行成功但平台显示部署失败(错误12180)

场景与执行脚本

通过Intune向设备推送PowerShell脚本,用于下载并执行卸载程序以移除特定应用,脚本内容如下:

$url = "some url to *.zip"
$DownloadFile = "C:\Users\Public\Downloads" + $(Split-Path -Path $url -Leaf)
$ExtractPath = "C:\Users\Public\Downloads"
Invoke-WebRequest -Uri $url -OutFile $DownloadFile
$ExtractShell = New-Object -ComObject Shell.Application
$ExtractFiles = $ExtractShell.Namespace($DownloadFile).Items()
$ExtractShell.Namespace($ExtractPath).CopyHere($ExtractFiles)
Start-Process $ExtractPath
Timeout /T 10
Start-Transcript
Start-Process -FilePath "C:\Users\Public\Downloads\*.exe" -ArgumentList "/S" -PassThru

异常现象

设备端验证显示脚本完整执行,目标应用已成功卸载,但Intune平台标记该部署为失败。

错误日志

DNS detection: WinHttpGetProxyForUrl call failed because of error 12180
DHCP detection: WinHttpGetProxyForUrl call failed because of error 12180

相关背景

推测脚本执行过程中尝试访问微软Intune服务地址:https://fef.msub03.manage.microsoft.com/TrafficGateway/TrafficRoutingService/SideCar/StatelessSideCarGatewayService,该问题涉及Intune服务的网络访问配置,可参考微软官方文档中关于Managed Desktop网络准备的内容。

缓解方案

  • 排查代理配置:错误12180属于代理访问失败类错误,需确认设备代理设置是否能正常访问Intune相关服务。可手动访问上述微软服务地址测试连通性;用netsh winhttp show proxy命令检查系统级WinHTTP代理配置是否正确,同时确认DHCP分配的代理地址有效。
  • 统一脚本执行上下文的代理:Intune脚本默认以系统账户运行,其代理配置可能与用户账户不一致。可在脚本中显式指定代理(如有需要),或针对微软服务地址添加跳过代理的逻辑。
  • 强制脚本返回成功退出码:Intune依据脚本退出码判断部署状态,即使实际操作成功,若脚本返回非0码仍会标记失败。可在脚本末尾添加Exit 0,确保正常执行后返回成功状态。
  • 完善网络允许列表:确保防火墙或代理服务器已放行Intune相关服务域名与IP,包括fef.msub03.manage.microsoft.com。
  • 优化脚本的错误处理:添加try-catch块捕获关键步骤错误,避免非关键操作(如打开下载目录)导致脚本异常退出;同时明确指定卸载程序路径,避免通配符匹配问题。优化后的脚本示例:
$url = "some url to *.zip"
$DownloadFile = Join-Path -Path "C:\Users\Public\Downloads" -ChildPath $(Split-Path -Path $url -Leaf)
$ExtractPath = "C:\Users\Public\Downloads"
# 替换为实际卸载程序的文件名,避免通配符匹配问题
$UninstallExe = Join-Path -Path $ExtractPath -ChildPath "your-uninstaller.exe"

try {
    # 下载压缩包
    Invoke-WebRequest -Uri $url -OutFile $DownloadFile -ErrorAction Stop
    
    # 解压文件(添加覆盖参数)
    $ExtractShell = New-Object -ComObject Shell.Application
    $ExtractFiles = $ExtractShell.Namespace($DownloadFile).Items()
    $ExtractShell.Namespace($ExtractPath).CopyHere($ExtractFiles, 16)
    
    # 等待解压完成,替代Timeout命令
    Start-Sleep -Seconds 10
    
    # 验证卸载程序存在后执行
    if (Test-Path -Path $UninstallExe) {
        $uninstallProcess = Start-Process -FilePath $UninstallExe -ArgumentList "/S" -PassThru -Wait
        # 根据卸载程序的退出码返回状态
        Exit $uninstallProcess.ExitCode
    } else {
        Write-Error "Uninstaller not found at $UninstallExe"
        Exit 1
    }
} catch {
    Write-Error "Script failed at step: $_"
    Exit 1
}

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.22 11:36:16