我试图安装Microsoft Office 2010,我已经创build了一个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}
我知道命令正在执行,因为安装程序正在创build一个日志文件,但日志只是突然停止https://gist.github.com/smudgerdan/62a5e44300a9590d6174
有什么意思,winrm不会等待setup.exe来完成? 我如何通过winrm安装Office 2010?
用不同的程序遇到类似的问题 – 发现一个* .bat与GPO指定的计划任务相结合,在所有的Windows版本/操作系统上都更加准确/有效。 有很多“[示例]”项目需要编辑,所以一定要扫描它。
这个脚本允许:1.validation操作系统2.validation程序是否已经安装3.卸载,如果已经安装,并清除configuration4.安装* .exe与所需的configuration5.创build集中式日志
如果不需要的话,任何这些特征都可以是“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.