Ref T5985. This is intended to fix issues introduced when using Cygwin OpenSSHD on Windows. By spawning a new Powershell session and running the command there, all of the appropriate environment variables are set up correctly.
There doesn't appear to be any way of restoring all the correct environment variables and settings for an existing process either, so we can't just repair the current environment.