Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

skp

Re: How to assign the result of a 'session.ExecuteCommand' in a variable using powershell script

Perfect! Thanks Martin
martin

Re: How to assign the result of a 'session.ExecuteCommand' in a variable using powershell script

It's only
$var2 = $session.ExecuteCommand($var1)
Write-Host $var2.Output
skp

How to assign the result of a 'session.ExecuteCommand' in a variable using powershell script

Hello,
While using a WINSCP remote execution powershell script, is there an option to assign the result of command executed through 'session.ExecuteCommand' to another variable?
For instance:
$var1="remote command1" 
$session.ExecuteCommand($var1)

The above command works as expected.
In order to assign the result of $session.ExecuteCommand($var1) into a variable(say $var2), is there an option using WINSCP powershell?
The following command line didn't work.
CommandExecutionResult $var2=$session.ExecuteCommand($var1)

The error message was 'CommandExecutionResult' is not a recognized command (within Powershell).

Thanks