我无法使用sysocmgr.exe在远程服务器上运行Windows组件的远程安装。它正在与psexec.exe \\ServerName -i sysocmgr.exe /i:%wnidir%\inf\sysoc.inf /u:\\path\to\components.txt
一起使用,但我希望使用PowerShell远程处理获得相同的结果。
我有使用WinRM的powershell远程处理工作正常,但我无法使用PowerShell远程运行sysocmgr.exe。
我在两台服务器(本地和远程)上做了什么:
Set-ExecutionPolicy unrestricted
Enable-PSRemoting
- 确定Set-Item WSMan:\localhost\Client\TrustedHosts *
让所有这些都在两台服务器上运行,我使用New-PSSession建立了一个持久的远程会话:
$s = NewPSSession -ComputerName Server1
然后我尝试启动PowerShell脚本(script.ps1),该脚本保存在可访问的共享上,并包含:
sysocmgr.exe /i:%wnidir%\inf\sysoc.inf /u:\\path\to\components.txt
我使用了Invoke-Command:
Invoke-Command -Session $s -FilePath \\NetworkShare\Scripts\script.ps1
启动上面的invoke-command后,我可以在任务管理器的远程服务器(server1)上看到,sysocmgr.exe正在运行,但它什么也没做。 Windows组件安装无法启动...
我尝试使用:
enter-pssession -computername Server1
- 工作得很好
我尝试启动script1.ps1并且它做了同样的事情,我可以在任务管理器中看到sysocmgr.exe,但它什么也没做......
我想我缺少一些与桌面交互的参数,比如psexec中的“-i”参数,我在powershell中找不到...
感谢您的帮助。
答案 0 :(得分:0)
我希望你的PowerShell脚本看起来像这样:
sysocmgr.exe "/i:${env:windir}\inf\sysoc.inf" "/u:\path\to\components.txt"