I'm encountering an issue when I try to install an .msi with my powershell script.
First the PS script that laucn the .msi install is executed remotely through an other PS script ( I show the line I used for that later in the explanation)
It's look like it launch the .msi but doesn't finalize the install but if try install the .msi with the exact same line with a .bat it install it without any issue.
At first I thought I may need admin right which could lead to an unfinalized install ? So I add with the parameter -Crendential admin cred but same issue.
Here is how I try to install the .msi with the Powershell and Batch :
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
The way I launched my PS script with Cred
#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
I hightly prefer to keep my PS script to launch the .msi install that why I asking for help Hope you guys can guide me
Deer
NB: There is no error showing up and that why I don't understand why it doesn't work
CodePudding user response:
I solved my issue by doing the following on my PS script
First variable to give the msi the argument I need
$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"
)
Then execute the .msi as follow :
Start-Process "msiexec.exe" -ArgumentList $MSIArguments -Wait -NoNewWindow
Maybe the wait help to make the script wait until the process is over so maybe it was the root of the issue ?
The variable to help argument to pass to the msi could also be the cause anyways it's now work fine for me