W
W
WindBridges2021-08-09 20:34:22
PowerShell
WindBridges, 2021-08-09 20:34:22

SSH + PowerShell, how to save variable values ​​between command calls?

Installed OpenSSH Server on a remote machine with Windows 10, configured it to work through PowerShell instead of Cmd, everything works fine, but now it was necessary to execute not a separate command, but a small script in which variables must be used. This code in one line works: $v = "Hello"; Write-Host $v, but if you send separately $v = "Hello"and Write-Host $v- then it doesn’t, because $v does not save the value between separate commands.

I know that PowerShell has commands like `New-Session`, but as far as I understand, they need to be used on the machine from which you connect, despite the fact that you need to connect from PowerShell. And I connect using SSH, and, apparently, this magic is not available here. Correct me if I'm wrong.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question