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

通过PowerShell远程卸载Office 2016的技术求助

企业环境下批量卸载Office 2016的PowerShell解决方案

原脚本存在的问题

  • 重复定义计算机名、重复获取凭证,代码冗余
  • 使用Get-WmiObject Win32_Product有风险:该命令会自动触发已安装MSI程序的修复操作,可能导致系统卡顿或应用异常
  • 仅匹配精准的"Microsoft Office 2016 Professional Plus"名称,无法卸载单独安装的Office 2016组件(如独立的Word/Outlook 2016)

优化后的远程卸载脚本(推荐)

这个脚本通过读取注册表获取卸载信息,避免Win32_Product的风险,同时确保卸载所有Office 2016关联组件:

# 配置参数
$computerNames = @("COMPUTERNAME1", "COMPUTERNAME2") # 可批量添加多台目标计算机
$credential = Get-Credential -Message "输入具有远程管理权限的账户"

# 远程执行卸载逻辑
Invoke-Command -ComputerName $computerNames -Credential $credential -ScriptBlock {
    # 定义Office 2016相关组件的识别关键词
    $office2016Keywords = @("Microsoft Office 2016", "Word 2016", "Excel 2016", "PowerPoint 2016", "Outlook 2016", "OneNote 2016", "Publisher 2016", "Access 2016")
    
    # 覆盖32位和64位系统的注册表卸载路径
    $uninstallPaths = @(
        "HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*",
        "HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*"
    )

    foreach ($path in $uninstallPaths) {
        # 筛选出所有匹配Office 2016的卸载项
        $uninstallItems = Get-ItemProperty -Path $path -ErrorAction SilentlyContinue | 
                          Where-Object { 
                              $_.DisplayName -and $office2016Keywords | Where-Object { $_.DisplayName -like "*$_*" }
                          }

        foreach ($item in $uninstallItems) {
            Write-Host "正在卸载: $($item.DisplayName)"
            # 静默执行卸载命令,不弹出交互窗口
            $uninstallCommand = "$($item.UninstallString) /quiet /norestart"
            Start-Process -FilePath "cmd.exe" -ArgumentList "/c $uninstallCommand" -Wait -NoNewWindow
        }
    }
}

脚本优势

  • 支持批量处理多台终端,无需重复配置
  • 读取注册表卸载信息,避免Win32_Product的自动修复风险
  • 覆盖所有Office 2016组件,确保卸载彻底
  • 静默模式执行,不干扰终端用户正常工作

额外注意事项

  • 执行账户必须拥有目标计算机的管理员权限
  • 卸载完成后建议重启终端(可在脚本末尾添加Restart-Computer -Force -Wait,但需提前通知用户)
  • 若企业使用Office部署工具(ODT),可直接使用官方卸载配置文件,更适合超大规模部署

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.08 12:54:56