when I work in remote-ssh to a Windows 2019 server (from Win10 client), if I need to run PowerShell commands that need to import a module, the command fails. If I run the same commands in Win10 or when logged on directly onto the Windows server all is good. This is one of those commands:
Get-ADComputer -Filter { (Enabled -eq $True) } -SearchBase $GsearchBaseOU
The error says: Get-ADComputer : Unable to contact the server. This may be because this server does not exist, it is currently down, or it does not have the Active Directory Web Services running.
But it is misleading and the problem seems to be that the ActiveDirectory module does not load. I tried loading it manually when in remote-ssh but it doesn't, and no error is thrown. Anybody experiencing the same? Any special config needed in VS Code maybe?
UPDATE: loading the module when connected with putty works. Executing commands as a consequence also works. As I suspect, the problem is with the remote-ssh plugin in VS Code. Anybody experiencing the same?
UPDATE2: by running:
ssh -T -D 64971 -F "C:\Users\[redacted]\.ssh\config" serverName powershell
in a simple cmd prompt, I successfully login, but when I run the PowerShell command above (or any cmd-let that requires to import a module) I have the same results. So it is not a remote-ssh plugin issue. I have removed vs code by doing an in-depth removal, reinstalled everything, reconfigured and I get the same result. On a different machine I configured vs code with remote-ssh and configured ssh access to the same server but without using a config file. So, I have to enter the password everytime I move from one workspace to another. And that works! It seems that by using a ssh config file with keyfile causes the problem, but I don't see how it could be...