Powershell does not seem to work over SSH

We have a single packer file that is intended to work for Linux and Windows. It creates a builder (“linux” or “windows”) and then runs several provisioners. Linux part works just fine. We are working on “windows” builder, and obviously need to replace all the “shell” provisioner with a windows equivalent - “powershell” being the obvious choice… Cannot get it to work right. I want to start by prefacing this with - we are using SSH transport for both windows and linux, since WinRM is incapable of handling data transfers in any sort of a reasonable volume (takes a minute under ssh, takes hours and hours under WinRM, not sure how long, never had the patience to wait that long) (Note: we are using the MS provided build of OpenSSH, to be clear)

Anyway, when using a “powershell” provisioner in Windows (Server 19) via SSH - it just does not work. The screen gets corrupted (a wall full of windows: lines) and … it hangs until it times out. Tried a lot of options, nothing seems to change it. I can see it transferring the PS file there and a PS wrapper to execute it, and tries to run it, and then nothing. Same thing happens with a simple inline one-liner - so it is not the content of the script.

Meanwhile, “windows-shell” seems to work just fine. We are in process of rewriting everything in batch, but PS is so much more powerful - it seems a shame to go back to 1980’s tech… Any ideas?

I could be wrong here, so take it for what it is.

I use the file provisioner to copy media from a folder from our git repository when it runs a pipeline. While it’s probably a little slower than SSH, it seems to work fine using WinRM as the communicator.

{
       "type": "file",
      "source": "../<folder>/",
      "destination": "/ProgramData/<folder1>/<folder2>/"
    }

Also, I don’t believe that there is a provisioner specifically for PS Core, which would be what you’d have in your linux instance. It may work, but you may need to link the pswh command as powershell.exe. I haven’t tried this yet, as we have a different team that manages linux. I guess I’ll have to give it a try sometime on my test box to see if I can get it it work.

Sorry if this is wrong, or doesn’t help you.