【发布时间】:2019-09-27 11:29:48
【问题描述】:
我正在尝试在我的 Active Directory 中的所有工作站上卸载 MS Office 2007。为此,我必须启动由UninstallConfig.xml 文件配置的C:\Transfer2007\setup.exe 以进行静默卸载(位于同一目录中)。 PowerShell 的Invoke-Command 没有返回任何错误,看起来一切都很好,但setup.exe 永远不会在目标工作站上启动。
当我手动启动 setup.exe 时,我收到“打开文件 - 安全警告”,我必须按“启动”。在下一步中,我被要求提供管理员访问权限 (UAC)。我认为这些弹出窗口是为什么 .exe 在尝试通过 PowerShell 远程运行时从不启动的问题。
我已经尝试在代码中包含以下内容:
–ExecutionPolicy Bypass-
-Credential具有管理员权限的参数
UninstallationConfig.xml文件:
<Configuration Product="ProPlus">
<Display Level="none" CompletionNotice="no" />
<SettingId="SETUP_REBOOT" Value="AutoAlways" />
</Configuration>
PowerShell 代码:
Invoke-Command -ScriptBlock {
Set-Location "C:\Transfer2007\";
.\SETUP.exe /uninstall ProPlus /config \UninstallConfig.xml
} -Credential mmb -ComputerName $Computer -AsJob
【问题讨论】:
标签: powershell active-directory executable uac invoke-command