Trouble passing arguments

Hello folks,
I am running this script against remote machines, but I cannot seem to get the .exe to execute. I believe my syntax is off. I am trying to get it installed silently:

Start-Process -FilePath “C:\Temp\Setup.exe” -ArgumentList “/s /v '”/qn’“” -NoNewWindow

If i run this locally it works, it installs the setup silently:
.\setup.exe /s /v"/qn"

Any ideas why my string is not working?

Thanks!

Please share how you are executing it remotely. My initial thought is you’ll need to add -Wait to start-process otherwise the remote connection will terminate taking setup.exe with it since it thinks its work is done.

Hey Matt,

do you get any errors on the remote machine? is it installshield setup? i had an issue recently deploying application using sccm.

I was running below powershell script:

$arg = "/s /f1$PSScriptRoot\myinstall.iss"
$setup = "$PSScriptRoot\someapp.exe"

Start-Process -FilePath $setup -ArgumentList $arg -NoNewWindow -wait

This worked on my machine, but when i packaged it on sccm the deployment failed. i got the error

The installation cannot be run by directly launching the MSI package. You must run setup.exe

searching the error online found that i needed to add ISSETUPDRIVEN=1

The deployment ended up working after adding it.

$msi = '/v" /qn ISSETUPDRIVEN=1"'
$arg = "/s /f1$PSScriptRoot\myinstall.iss $msi"
$setup = "$PSScriptRoot\someapp.exe"
Start-Process -FilePath $setup -ArgumentList $arg -NoNewWindow -wait

only suggesting this because i saw the switch /v"/qn"
hope it helps

Im connecting with Invoke-Command

Thanks mawazo and krzydoug, I tried both suggestions, It doesnt error, it just hangs when it says agent found, installing:

Here is a bigger clip of the script:

Invoke-Command -ComputerName $remotecomputer -ScriptBlock {
    $servicename = 'BesClient'
    $hostname = hostname
	$msi = '/s /v"/qn ISSSETUPDRIVEN=1"'
	$arg = "/i c:\temp\setup.exe $msi"
    $bes = Get-Service -Name $servicename -ErrorAction SilentlyContinue
    If ($bes.Status -eq 'Running') {
        Write-Host "BigFix is already Installed and Running!" -ForegroundColor Yellow
        Get-Service -DisplayName "Bes Client" -ErrorAction SilentlyContinue
        Get-Service -DisplayName "Bes Client" | Out-File -FilePath "C:\Temp\$hostname-BESService.txt"
        Read-Host -Prompt "Press Enter key to continue"
        Break
    }
    else {
        Write-Host "BigFix agent found, starting install" -ForegroundColor Yellow
        Start-Process -FilePath "C:\temp\setup.exe" -ArgumentList $arg -NoNewWindow -wait
        Get-Service -DisplayName "*Bes*"
        write-host "BigFix is installed"
    }

You provide the executable via -FilePath and again via -ArgumentList … are you sure that’s correct? :wink:

Why using all these variables? That makes your code harder to read.

If you want to install something remotely and silent you should not have a Read-Host in your code. :wink:

Especially for trouble shooting I’d reduce the code to the bare minimum:

Invoke-Command -ComputerName $remotecomputer -ScriptBlock {
    $bes = Get-Service -Name 'BesClient' -ErrorAction SilentlyContinue
    If ($bes.Status -eq 'Running') {
        Write-Host "BigFix is already Installed and Running!" -ForegroundColor Yellow
    }
    else {
        Write-Host "BigFix agent found, starting install" -ForegroundColor Yellow
        Start-Process -FilePath "C:\temp\setup.exe" -ArgumentList '/s /v"/qn ISSSETUPDRIVEN=1"' -NoNewWindow -wait
        Get-Service -DisplayName "*Bes*"
        write-host "BigFix is installed"
    }
}

And just to have it mentioned at least once … the setup executable has to be saved on the remote computer - not your local computer. :point_up_2:t4:

2 Likes

Olaf, That did it. Yea I didnt really give that version a good look over. I use this just as a tool for myself, I was going to make another version completely silent that can be run against a .txt file of multiple systems. But yea I use these as tools just for myself for now, so I use read-host etc…

I saw I had a typo in ISSETUPDRIVEN also, had an extra S in there, not sure if that was the problem. I like it with less variables as well :+1:

Yes, I copy the exe to the remote machine before that clip of the script.

Thanks for all help everyone!

-Matt

My bad with the typo matt

mawazo,
No worries, thanks for the help!

-matt