Reputation: 23
The more forums i look on, the more confused i get, and i've found very similar posts, but not exactly what i'm looking for, i'm a powershell newbie, can someone tell me the best way of being able to write this in powershell.
I can get the program to launch but it's passing the parameters and the syntax i'm struggling with. To make it easier to read i have removed any formatting from the $programArgs command so i'm hoping it's just putting in the correct synatax around it.
This is what i have so far:-
$program = "C:\Program Files (x86)\PuTTY\psftp.exe"
$programArgs = "-pw 1234 -P 10023 -i D:\sftp\Keys\mykey.ppk [email protected] -b d:\sftp\Scripts\GetAll.txt"
Invoke-Command -ScriptBlock { & $program $programArgs }
Upvotes: 1
Views: 5759
Reputation: 23
To Clarify this is the command i used to launch psftp and pass various parameters:-
Start-Process -FilePath "c:\Program Files (x86)\PuTTY\psftp.exe" -ArgumentList "-pw Password123 -P 10023 -i D:\Keys\pub.ppk [email protected] -b d:\Scripts\GetAll.txt" -Wait -NoNewWindow
Upvotes: 1
Reputation: 26424
Should be able to just use Invoke-Expression "$program $programArgs"
.
Upvotes: 1