I have an executable that I need to install remotely. It currently works if with invoke-command if I have the full install command in the -scriptblock section with all the appropriate switches appended.
invoke-command -computername $computername -scriptblock{Path.exe /switches}
The issue is that the switches include keys that have to be changed on a scheduled basis, so I'm trying to pull the information into a variable that I can run inside the scriptblock.
invoke-command -computername $computername -argumentlist $installcommand -scriptblock {$installcommand}
This does not work, even though the $installcommand variable contains the same path.exe /switches. I can verify this by printing out the value of the variable. I also tried $using:installcommand with no success.
So I tried using start-process inside the scriptblock:
invoke-command -computername $computernam -argurmentlist $installcommand -scriptblock {start-process -filepath $installcommand
and
invoke-command -computername $computername -argurmentlist $installcommand, $installargs -scriptblock {start-process -filepath $installcommand -argumentlist {$installargs}}
Neither of which work, even when I try $using: for the variables
How do I get invoke command to run an executable when the path and the arguments are in variable/s?