I am trying to use Power-shells Invoke to run an MSI install.
This code is not runing the MSI install.
param ($path1, $path2, $path3)
write-output "path1= $path1"
write-output "path2= $path2"
write-output "path3= $path3"
$PathToMSI = "D:\Install\$path1\'$path2$path3'"
write-output "PathToMSI= $PathToMSI"
$scriptblock = {Start-Process msiexec.exe -Argumentlist "/i $PathToMSI","/qn"}
invoke-command -scriptblock $scriptblock
I know that my PathToMSI is correct, as this is what is displayed, but it's not executing.
path1= 20191213.3
path2= X Y Z
path3= .msi
PathToMSI= D:\Install\20191213.3\'X Y Z.msi'
If I run it hard coded it works?
Invoke-Command -ScriptBlock {
D:\install\20191213.3\'X Y Z.msi' /quiet
}
It seems that the PathToMSI is not resolving to it's value. I have reviewed a few like Error invoking command to install a Msi through Powershell