powershell - Remote install MSI package not working when logged off
问题描述
I've got a problem with my script I'm working on. One part of this script should remotely install a MSI package. The problem is that it only works while I'm logged in to the target servers.
Here's the code I'm using:
1st try:
Invoke-Command -ComputerName $Computer -ScriptBlock {
cd "C:\FlexAgent"
Start-Process msiexec.exe -ArgumentList "/i 'FlexNet Inventory Agent.msi' /qn /l newlogfile.txt"
}
2nd try:
Invoke-Command -ComputerName $Computer -ScriptBlock {
cd "C:\FlexAgent"
Invoke-Expression "msiexec /i 'FlexNet Inventory Agent.msi' /qn /l logfile.txt"
}
3rd try:
Invoke-Command -ComputerName $Computer -ScriptBlock {
cd "C:\FlexAgent\"
& msiexec /i 'FlexNet Inventory Agent.msi' /qn '/l*v' 'logfile.txt'
}
Folder: FlexAgent:
Directory: \\RemoteComputer\c$\FlexAgent
Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 03.08.2018 09:47 ManageSoft upgrade agent
-a--- 08.08.2017 12:34 15203756 Data1.cab
-a--- 08.08.2017 12:34 3089408 FlexNet Inventory Agent.msi
-a--- 03.08.2018 11:26 2 logfile.txt
-a--- 29.05.2018 09:41 6985 mgssetup.ini
-a--- 08.08.2017 12:34 1308656 setup.exe
-a--- 08.08.2017 12:34 5350 Setup.ini
I wasn't able to find any further information in the log files I defined or the logfiles in the event viewer. The logfiles are being created but they are empty.
Is there a way to install this MSI package unattended without the need to be logged in?
More Infos:
- Target Servers: Windows Server 2008 - 2016
- Script Server: Windows Server 2012 R2
- Domain: Yes, they are all in the same domain.
- User: Logged in with a Domain Admin
- Network: All in the same network
- Firewall:
- TCP/5985 not blocked (used for remote PowerShell)
- TCP/5986 not blocked (used for remote PowerShell)
解决方案
我刚刚找到了解决方案。我可以使用以下命令远程安装 MSI 包:
$product= [WMICLASS]"\\$RemoteComputer\ROOT\CIMV2:win32_Product"
$product.Install("C:\FlexAgent\FlexNet Inventory Agent.msi")
即使在注销时它也能正常工作。
推荐阅读
- python - 编写运行计划
- javascript - 反应选择选项没有正确显示
- apache-kafka - 尝试将元组写入 Flink Kafka 接收器
- sql-server - SQL 查询设计 - 仅当一个动作发生在集合中的另一个动作之前时才进行求和/计数
- r - 使用串扰链接传单地图和数据表时删除表中的经纬度列
- xamarin.forms - Appcenter Push:无法显示通知
- android - 以编程方式连接到热点(无互联网)的 android 设备切换回带互联网的 wifi
- python - Python 2.7 无法从 cmd.exe Windows 10 加载 DLL(VC2017 内置)
- c# - 23 kB XML 文件的解析速度超过半秒
- jenkins - 如何获取当前的 Jenkins 流水线 StepContext