Dockerfile and MSI installation - powershell

I'm trying to install an application that is an MSI file during the build process of an image with Dockerfile.
I can get the MSI to install properly when I enter a PowerShell session on the container by running:
C:\Windows\Syswow64\msiexec.exe /i "C:\Folder\File Name with spaces.msi" /qn /l*v "C:\log.log"
I have tried everything I can think with various RUN commands using powershell and cmd in the dockerfile.
Anyone have any ideas if this is just a matter of properly escaping quotes or the spaces?
Thanks,

Using powershell you can install msi file using below piece of code.
$msiPath = "your msi file path"
$arguments = "/i `"$msiPath`" /quiet"
Start-Process msiexec.exe -ArgumentList $arguments -Wait
Use same quotes

Related

generate a war file using Powershell

I am new to Powershell.I am trying to generate a war file in the location of jar.exe , any inputs highly appreciated.
I have tried to generate the war file using Start Process, But it is not generating the war file
$wargen=Start-Process -FilePath "cmd.exe" -ArgumentList "/K cd /d D:\Temp\ws\9.0\base\java\8.0\bin\jar.exe -cvf foo.war" -Verb "runas" -Verbose
You don't need to try so hard. It's not necessary to invoke Start-Process or cmd.exe to run a command. PowerShell is a shell; it can run commands. Just type the command at the PowerShell prompt and press Enter.
PS C:\> D:\Temp\ws\9.0\base\java\8.0\bin\jar.exe -cvf foo.war
I am wondering about why your example uses the runas shell verb to run the command as an elevated process; my guess is that this is unnecessary.

Powershell script is not installing an exe while i try it runs through TFS Build

I have a powershell script which will install an exe. It works fine when i try it from a powershell ISE console, but it fails when i try it from TFS build step.
Note : My TFS user, agent user and triggering user are same.
Could anybody can shed some light on this issue ?
Start-Process -FilePath $installerFileName -Verb "runas" -ArgumentList $parameter -Wait
The above code is using to install the exe. $parameter is a list of custom parameters.
I am getting below error
[WixSession.GetSession][GetSessionValues]exception: Value cannot be null. Parameter name: s
What kind of exe are you trying to install? Dose that support silent installation? If UI pop up during the installation, then the agent needs to run in interactive mode.
Test on my side with below command to install/unistall the notepad++ with service mode, everyting works as expected:
start-process -FilePath "D:\Software\npp.7.5.8.Installer.x64.exe" -ArgumentList '/S' -Verb runas -Wait
And:
start-process -FilePath "C:\Program Files\Notepad++\uninstall.exe" -ArgumentList '/S' -Verb runas -Wait

Installing an MSI file on a remote machine with PowerShell

I'm working on a utility to automate some processes and one task is to install a .msi file on a remote machine. The file is found in C:\Users\username on the remote machine and for simplicity's sake, the filename is file.msi. The command I'm using is:
Invoke-Command -ComputerName $remoteMachine -ScriptBlock{cmd /c start /wait msiexec /i $installPath /quiet}
When I execute this on my local dev machine, it doesn't show any errors, but doesn't install the file.
However, when I copy the exact command inside the brackets and run it in a PowerShell script on the remote machine, it installs successfully. I know my $remoteMachine is correct because I use it extensively throughout the rest of the script.
I know the $installPath variable also isn't the issue because for testing purposes I hardcoded the full path and it still doesn't install.
I also have proper permissions on the remote machine because earlier in the script I copy and paste the .msi from one machine to another without a problem.
I've tried a combination of commands and have been stuck here for a while, so any help would be greatly appreciated!
Ideally, this should work.
Invoke-Command -ComputerName $remoteMachine -ScriptBlock{msiexec /i $installPath /quiet}
The reason it is failing is coz you are not passing the $installPath as argumentlist. Modify it like this.
Invoke-Command -ComputerName $remoteMachine -ScriptBlock{
param(
[Parameter(Mandatory=$true,
Position=0)]
$installPath
)
cmd /c start /wait msiexec /i $installPath /quiet
} -ArgumentList $installPath
But if it isn't working, here is a workaround that I used a while ago.
Create a .bat file with the command msiexec /i $installPath /quiet and push it to the location just like you pushed the msi file.
Now from the invoke scriptblock, simply call the bat file instead.
Invoke-Command -ComputerName $remoteMachine -ScriptBlock{C:\Users\Username\Install.bat}
where Install.bat is the name of your bat file.
Note: You might want to use the /norestart switch as well if you are not looking to cause a reboot. Depends on what you are trying to install.
Beginning in PowerShell 3.0, you can use the Using scope modifier to identify a local variable in a remote command.
syntax of Using :- $Using:<VariableName>
In your case :
Invoke-Command -ComputerName $remoteMachine -ScriptBlock{cmd /c start /wait msiexec /i $Using:installPath /quiet}
https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_remote_variables?view=powershell-7.2#using-local-variables

How to silently install exe using powershell

I am trying to install trial version of Lotus Notes Designer using Powershell command
Start-Process -FilePath "EXEPath" -Verb runAs -ArgumentList "/qn"
But this command displays the normal installation wizard, how do I make it a silent installation?
Silent Install commands vary depending on the program itself and the installer they have used. Using /qn will work for most (but not all!) MSI installers, as there is a Microsoft standard that most will follow, but EXE installers can be very different as they do not have guidelines like an MSI.
Searching for the name of the program and 'silent install' will likely bring up the programs help pages or a blog which lists the commands you will need to use.
A search for "lotus notes designer silent install" brings up this article which lists the command as:
setup.exe /s /v"/qn"
Which you would use like this:
Start-Process -FilePath "C:\folder\setup.exe" -Verb runAs -ArgumentList '/s','/v"/qn"'
Note: I can't test this as I don't use Lotus Notes, but it should work, or at least give you a good idea on what to do.
Please try below command in powershell, it will install silently along with wait and ouput. Note: Your installer should be supporting /S option and didn't try with LotusNotes.
Start-Process .\installer.exe /S -NoNewWindow -Wait -PassThru
use this
Start-Process -FilePath "D:\Software\app.exe /S /NoPostReboot _?=D:\Software\app.exe" -NoNewWindow -Wait -PassThru $process.ExitCode

Power Shell Invoking an MSI

I am trying to run an msi installer file using powershell. Below is my power shell code:-
$argumentlist = "/i D:\FolderTest\InstallerTest 1.9.0.39621 Setup.msi /qn /l*v D:\FolderTest\InstallLog.log"
Start-Process -FilePath "C:\Windows\System32\msiexec.exe" -ArgumentList $argumentlist
Every time I try to run this code though The Windows installer appears telling me that the argumentList variable isnt set correctly. Can anybody tell me what the problem is with this code?
I think that spaces in the msi filename are what's preventing the msiexec to work properly. Try something like:
$argumentlist = "/i 'D:\FolderTest\InstallerTest 1.9.0.39621 Setup.msi' /qn /l*v D:\FolderTest\InstallLog.log"
PowerShell is a shell. It's designed to run commands you type. You don't need to use Start-Process. Just type the command and press Enter.
PS C:\> msiexec /i "D:\FolderTest\InstallerTest 1.9.0.39621 Setup.msi" /qn /l*v "D:\FolderTest\InstallLog.log"
As with any command, if a parameter contains spaces, enclose it in quotes.