0

I am using New-PSSession to create session and connect to our server.

Code I am using looks like this:

$PWord = ConvertTo-SecureString -String $passwordPlain -AsPlainText -Force
$credentials = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $userName, $PWord
$serverSession = New-PSSession -ComputerName $serverName -Credential $credentials

And it works perfectly. But if my colleague runs it on his PC with same parameters it fails with error: The user name or password is incorrect. For more information, see the about_Remote_Troubleshooting Help topic.

It looks like my colleague does not have permissions to connect there. If this is the case, what are $credentials for?

We have tried setting -Authentication to different type, but with no luck. Then we tried different credentials on my PC and it works.

Have anyone encountered this problem?

  • See [this](https://stackoverflow.com/a/15581334/9898643) and [that](https://www.pdq.com/blog/secure-password-with-powershell-encrypting-credentials-part-2/). SecureStrings created on one machine cannot be used from another machine unless you provide an encryptuion key using the `-Key` parameter. – Theo Jun 29 '23 at 14:31

0 Answers0