无法通过 winrm 安装 Office 2010

无法通过 winrm 安装 Office 2010

我正在尝试安装 Microsoft Office 2010,我已经创建了一个 MSP 和 config.xml 文件,因此我可以使用以下命令从 Powershell 执行此操作:

Start-Process "C:\temp\Office2010\x86\setup.exe" -ArgumentList "/config `"Config.xml`" /adminfile `"custom.MSP`"" -Wait -NoNewWindow

这很完美。等待 setup.exe 完成后,Office 就安装好了。

但是使用以下命令从远程计算机运行相同的命令:

Invoke-Command -computer computer -Credential user -ScriptBlock { Start-Process "C:\temp\Office2010\x86\setup.exe" -ArgumentList "/config `"Config.xml`" /adminfile `"custom.MSP`"" -Wait -NoNewWindow}

我知道命令正在执行,因为安装程序正在创建日志文件,但日志突然停止https://gist.github.com/smudgerdan/62a5e44300a9590d6174

是否有某种原因意味着 winrm 不会等待 setup.exe 完成?如何通过 winrm 安装 Office 2010?

答案1

使用其他程序时也遇到了类似的问题 - 发现 *.bat 与 GPO 指定的计划任务相结合,对所有 Windows 版本/操作系统都更加准确/有效。有许多“[example]”项目需要编辑,因此请务必仔细检查。

该脚本可以:1. 验证操作系统 2. 验证程序是否已安装 3. 如果已安装则卸载并清除配置 4. 使用所需配置安装 *.exe 5. 创建集中日志

如果不需要的话,这些功能中的任何一个都可以是“REM”。

请参阅下文:

Rem This is to install a program using a batch file - this can be triggered by a GPO scheduled task item.

Rem -------------------Variables to Adjust----------------------
Rem
Rem 1. Location of exe and batch file source - 
Rem     a. Everyone has full or r/w access to (possibly a SHARE)
Rem     b. Has no spaces in path
Rem
set DeployDirectory=\\[IP\Client\Windows\Office2010\]
REm
Rem 2. Location of logs
Rem 
set logshare=\\[IP\Client\Windows\Office2010\logs]
Rem
Rem 3. Change commands to go with *.exe if needed.
Rem
set CommandLineOptions=["/config `"Config.xml`" /adminfile `"custom.MSP`"" -Wait -NoNewWindow]
Rem
Rem
Rem --------------------------------------------------------------

IF EXIST "%PROGRAMFILES(X86)%" (GOTO 64BIT) ELSE (GOTO 32BIT)

:64BIT
wmic product where name="[name of program when viewing "programs and features]" call uninstall
wmic product where name="[name of program when viewing "programs and features]" call uninstall
REG DELETE HKLM\SOFTWARE\[name of program in regedit] /F
echo deployment x64 %ComputerName%
"%DeployDirectory%\[Nameoffilex64.exe]" %commandlineoptions%
if %errorlevel% neq 0 (GOTO ERRORED) ELSE (GOTO Complete)

:32BIT
wmic product where name="[name of program when viewing "programs and features]" call uninstall
wmic product where name="[name of program when viewing "programs and features]" call uninstall
REG DELETE HKLM\SOFTWARE\[name of program in regedit] /F
echo deployment x32 %Computername%
"%DeployDirectory%\[Nameoffilex86.exe]" %commandlineoptions%
if %errorlevel% neq 0 (GOTO ERRORED) ELSE (GOTO Complete)

:Complete
echo %date% %time% the %0 script has completed successfully >> %logshare%\%ComputerName%.log
Rem pause
GoTo END

:Errored
echo %date% %time% Deployment ended with error code %errorlevel%. >> %logshare%\%ComputerName%.log
Rem pause
GoTo END

:End

echo GoodBye
Rem pause   




 Please let me know if this resolves the issue.

相关内容