# Trouble passing arguments

**URL:** <https://forums.powershell.org/t/trouble-passing-arguments/21322>\
**Category:** PowerShell Help\
**Created:** [January 8, 2023, 12:25am UTC](https://forums.powershell.org/t/trouble-passing-arguments/21322 "2023-01-08T00:25:13Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![matt1974](https://avatars.discourse-cdn.com/v4/letter/m/dbc845/32.png) [@matt1974](https://forums.powershell.org/u/matt1974)\
**Post date:** [January 8, 2023, 12:25am UTC](https://forums.powershell.org/t/trouble-passing-arguments/21322/1 "2023-01-08T00:25:13Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![krzydoug](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/krzydoug/32/1008_2.png) [@krzydoug](https://forums.powershell.org/u/krzydoug)\
**Post date:** [January 8, 2023, 1:29am UTC](https://forums.powershell.org/t/trouble-passing-arguments/21322/2 "2023-01-08T01:29:40Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![mawazo](https://avatars.discourse-cdn.com/v4/letter/m/48db29/32.png) [@mawazo](https://forums.powershell.org/u/mawazo)\
**Post date:** [January 8, 2023, 1:46am UTC](https://forums.powershell.org/t/trouble-passing-arguments/21322/3 "2023-01-08T01:46:22Z")

</div>

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:

```auto
$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.

```auto
$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

---

<div class="post-metadata">

**Author:** ![matt1974](https://avatars.discourse-cdn.com/v4/letter/m/dbc845/32.png) [@matt1974](https://forums.powershell.org/u/matt1974)\
**Post date:** [January 8, 2023, 2:09am UTC](https://forums.powershell.org/t/trouble-passing-arguments/21322/4 "2023-01-08T02:09:31Z")

</div>

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:

```auto
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"
    }

```

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [January 8, 2023, 2:35am UTC](https://forums.powershell.org/t/trouble-passing-arguments/21322/5 "2023-01-08T02:35:49Z")

</div>

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

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. 😉

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

```auto
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. 👆🏽

---

<div class="post-metadata">

**Author:** ![matt1974](https://avatars.discourse-cdn.com/v4/letter/m/dbc845/32.png) [@matt1974](https://forums.powershell.org/u/matt1974)\
**Post date:** [January 8, 2023, 2:48am UTC](https://forums.powershell.org/t/trouble-passing-arguments/21322/6 "2023-01-08T02:48:02Z")

</div>

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 👍

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

Thanks for all help everyone!

-Matt

---

<div class="post-metadata">

**Author:** ![mawazo](https://avatars.discourse-cdn.com/v4/letter/m/48db29/32.png) [@mawazo](https://forums.powershell.org/u/mawazo)\
**Post date:** [January 8, 2023, 2:52am UTC](https://forums.powershell.org/t/trouble-passing-arguments/21322/7 "2023-01-08T02:52:39Z")

</div>

My bad with the typo matt

---

<div class="post-metadata">

**Author:** ![matt1974](https://avatars.discourse-cdn.com/v4/letter/m/dbc845/32.png) [@matt1974](https://forums.powershell.org/u/matt1974)\
**Post date:** [January 8, 2023, 3:13am UTC](https://forums.powershell.org/t/trouble-passing-arguments/21322/8 "2023-01-08T03:13:07Z")

</div>

mawazo,  
No worries, thanks for the help!

-matt

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:16pm UTC](https://forums.powershell.org/t/trouble-passing-arguments/21322/9 "2024-05-16T20:16:08Z")

</div>


