.msi 安装的 powershell 脚本问题
Problem with powershell script for an .msi install
我在尝试使用我的 powershell 脚本安装 .msi 时遇到问题。
首先是 PS 脚本,laucn .msi 安装是通过另一个 PS 脚本远程执行的(我在后面的解释中显示了我使用的行)
看起来它启动了 .msi,但没有完成安装,但如果尝试使用与 .bat 完全相同的行安装 .msi,它会毫无问题地安装它。
起初我以为我可能需要管理员权限,这可能会导致安装未完成?所以我添加了参数 -Credential admin cred 但同样的问题。
以下是我尝试使用 Powershell 和 Batch 安装 .msi 的方法:
msiexec /i C:\Windows\Temp\GLPI-Agent-1.3-gitd32af0ff-x64.msi /quiet ADD_FIREWALL_EXCEPTION=1 RUNNOW=1 SERVER='http://$IP/glpi/front/inventory.php' ADD_FIREWALL_EXCEPTION=1 DEBUG=1 RUNNOW=1 TASK_FREQUENCY=daily
我使用 Cred
启动 PS 脚本的方式
#Cred
$PWD=ConvertTo-SecureString "RANDOM_PWD" -AsPlainText -Force
$creds = new-object System.Management.Automation.PSCredential (".\localadmin", $PWD)
Invoke-command -Credential $creds -FilePath C:\Users\myuser\Desktop\Test\checkversion.ps1 -ComputerName $TargeteName -ArgumentList $VersionInstall
我非常希望保留我的 PS 脚本来启动 .msi 安装,这就是我寻求帮助的原因
希望大家多多指导
鹿
注意:没有出现错误,这就是为什么我不明白为什么它不起作用
我通过在我的 PS 脚本上执行以下操作解决了我的问题
为 msi 提供我需要的参数的第一个变量
$MSIArguments = @(
"/i"
"C:\Windows\Temp\GLPI-Agent-1.3-gitd32af0ff-x64.msi"
"/quiet"
"ADD_FIREWALL_EXCEPTION=1"
"RUNNOW=1"
"SERVER='http://$AnRandomIP/glpi/front/inventory.php'"
"ADD_FIREWALL_EXCEPTION=1"
"DEBUG=1"
"RUNNOW=1"
"TASK_FREQUENCY=daily"
)
然后按如下方式执行.msi :
Start-Process "msiexec.exe" -ArgumentList $MSIArguments -Wait -NoNewWindow
也许等待有助于让脚本等到进程结束,所以这可能是问题的根源?
帮助参数传递给 msi 的变量也可能是原因,无论如何它现在对我来说工作正常
我在尝试使用我的 powershell 脚本安装 .msi 时遇到问题。
首先是 PS 脚本,laucn .msi 安装是通过另一个 PS 脚本远程执行的(我在后面的解释中显示了我使用的行)
看起来它启动了 .msi,但没有完成安装,但如果尝试使用与 .bat 完全相同的行安装 .msi,它会毫无问题地安装它。
起初我以为我可能需要管理员权限,这可能会导致安装未完成?所以我添加了参数 -Credential admin cred 但同样的问题。
以下是我尝试使用 Powershell 和 Batch 安装 .msi 的方法:
msiexec /i C:\Windows\Temp\GLPI-Agent-1.3-gitd32af0ff-x64.msi /quiet ADD_FIREWALL_EXCEPTION=1 RUNNOW=1 SERVER='http://$IP/glpi/front/inventory.php' ADD_FIREWALL_EXCEPTION=1 DEBUG=1 RUNNOW=1 TASK_FREQUENCY=daily
我使用 Cred
启动 PS 脚本的方式#Cred
$PWD=ConvertTo-SecureString "RANDOM_PWD" -AsPlainText -Force
$creds = new-object System.Management.Automation.PSCredential (".\localadmin", $PWD)
Invoke-command -Credential $creds -FilePath C:\Users\myuser\Desktop\Test\checkversion.ps1 -ComputerName $TargeteName -ArgumentList $VersionInstall
我非常希望保留我的 PS 脚本来启动 .msi 安装,这就是我寻求帮助的原因 希望大家多多指导
鹿
注意:没有出现错误,这就是为什么我不明白为什么它不起作用
我通过在我的 PS 脚本上执行以下操作解决了我的问题
为 msi 提供我需要的参数的第一个变量
$MSIArguments = @(
"/i"
"C:\Windows\Temp\GLPI-Agent-1.3-gitd32af0ff-x64.msi"
"/quiet"
"ADD_FIREWALL_EXCEPTION=1"
"RUNNOW=1"
"SERVER='http://$AnRandomIP/glpi/front/inventory.php'"
"ADD_FIREWALL_EXCEPTION=1"
"DEBUG=1"
"RUNNOW=1"
"TASK_FREQUENCY=daily"
)
然后按如下方式执行.msi :
Start-Process "msiexec.exe" -ArgumentList $MSIArguments -Wait -NoNewWindow
也许等待有助于让脚本等到进程结束,所以这可能是问题的根源?
帮助参数传递给 msi 的变量也可能是原因,无论如何它现在对我来说工作正常