SSH connection with PowerShell and Putty

Hello

I am opening an SSH session from PowerShell by using plink.

&($plinkpath + "plink.exe") -pw $password $username@$servername -m $myscript

The problem is I am struggling to get a value of a variable from this session to use it for the my powershell script.

Any help please ?

Thanks in advance

Hi hethkelff, welcome to the forum! :wave:

I’m afraid I am unable to discern what you mean by this. Do you mean there is a variable inside the session and you want to pull it out? If so, sounds like you just need to output the contents of the variable in the session and that will be the output of the powershell command.

Either way, can you please clarify/illustrate what you mean by this?

Hello krzydoug,

Thanks for this reply.
I found the solution today and it’s not a complicated one actually.
I used Invoke-Command like this:

$row_data = Invoke-Command -ScriptBlock { scriptbolck…}

and then I got arguments of $row_data: $row_data[0]…

Best regards;