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

Advertisement

skp
Joined:
Posts:
2
Location:
India

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

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,392
Location:
Prague, Czechia

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

Reply with quote

Advertisement

You can post new topics in this forum