Cant get Powershell window to close after calling winscp
Im launching winscp to transfer a file. It works great but I cannot figure out how to get the powershell window to close. I have close and exit at the end. What happens is it echos back on the screen Session closed no session but it doesn't exit, it just stays like its waiting something. The only way I can get back to the prompt is a control c.
Id really like it to just connect, transfer, close, and exit....BTW if i use WinSCP.exe instead of com then Powershell launches a separate window which does close but the 1st is left behind. Can someone help?
$localfile = 'C:\folderA\* '
$remoteloc = '/home/ms/folderB/'
$movefile = '"put '+ $localfile + $remoteloc + '"'
$winscp = "c:\Program Files (x86)\WinSCP\WinSCP.com"
#Connection string format username:password@appliance_name:port#
$FWconn = '"open sftp://username:password@servername:port"'
Start-Process -NoNewWindow -PassThru -FilePath $winscp -ArgumentList '/console', '/command', $FWconn, '"option batch aborzt"', '"option confirm off"', '"option transfer binary"', $movefile, 'close', 'exit'
Thanks
Id really like it to just connect, transfer, close, and exit....BTW if i use WinSCP.exe instead of com then Powershell launches a separate window which does close but the 1st is left behind. Can someone help?
$localfile = 'C:\folderA\* '
$remoteloc = '/home/ms/folderB/'
$movefile = '"put '+ $localfile + $remoteloc + '"'
$winscp = "c:\Program Files (x86)\WinSCP\WinSCP.com"
#Connection string format username:password@appliance_name:port#
$FWconn = '"open sftp://username:password@servername:port"'
Start-Process -NoNewWindow -PassThru -FilePath $winscp -ArgumentList '/console', '/command', $FWconn, '"option batch aborzt"', '"option confirm off"', '"option transfer binary"', $movefile, 'close', 'exit'
Thanks