I think this has been asked many times yet I can't find an answer that works for me.
- I need to construct a command line from variables.
- I need to run that command line executable.
- I need to have the results spew out onto the same screen as my script.
I'm trying to run Putty SCP with a custom source and destination.
I've messed around with & and Invoke-Expression but its impossible. Some simple #1 use-case things in PowerShell are so incredibly hard they eat away at all that's good about it.
The only way I can see to do this is to run it within a new Process instance and setup all the output redirection and then pipe it back out on the PS screen after it finished.
And I know this could fail because the output buffer can get full unless you're hooked-into the events and are scooping it out.
The other way is to write my command line to a batch file and run that.
Any help appreciated. There has to be a simpler way.
Edit
For example:
[string]$scpPath = Find-PathToPuttyScpExecutable;
[string]$scpArguments = "-v -r -pw " + $MarkLogicServerPassword + " " + $MarkLogicSourcePath + " " + $MarkLogicServerUserName + "@" + $ServerName + ":" + $MarkLogicDestinationRootPath
I need to execute $scpPath + " " + $scpArguments.