Please consider the following scenario:
There are 2 servers: server1 and server2, both on the same network and on the same domain. The objective is to open a PSSession from server1 into server2 using a local user from server2 as the identity:
PS @SERVER1 > $session = New-PSSession -ComputerName server2 -Credential server2\username
The local user on server2 is a member of the WinRMRemoteWMIUsers_ group
If a domain user is used then all works fine:
PS @SERVER1 > $session = New-PSSession -ComputerName server2 -Credential domain\username
The error obtained when trying to connect as a local user is:
New-PSSession : [server2] Connecting to remote server server2 failed with the following error message : WinRM cannot process the request. The following error with errorcode 0x80090311 occurred while using Kerberos
authentication: There are currently no logon servers available to service the logon request.
Possible causes are:
-The user name or password specified are invalid.
-Kerberos is used when no authentication method and no user name are specified.
-Kerberos accepts domain user names, but not local user names.
-The Service Principal Name (SPN) for the remote computer name and port does not exist.
-The client and remote computers are in different domains and there is no trust between the two domains.
After checking for the above issues, try the following:
-Check the Event Viewer for events related to authentication.
-Change the authentication method; add the destination computer to the WinRM TrustedHosts configuration setting or use HTTPS transport.
Note that computers in the TrustedHosts list might not be authenticated.
-For more information about WinRM configuration, run the following command: winrm help config. For more information, see the about_Remote_Troubleshooting Help topic.
From the error message there is The following error with errorcode 0x80090311 occurred while using Kerberos authentication and -Kerberos accepts domain user names, but not local user names. so, a connection was attempted after executing the following on server1:
PS @SERVER1 > winrm set winrm/config/client '@{TrustedHosts="server2"}'
Attempting to start a PSSession after the command is executed still fails.
What other step can be attempted?
You should be able to do something like this
$cred = $host.ui.PromptForCredential("local credential", "Enter machine\user ID and password.", "localhost\$env:username", "")
$session = New-PSSession -ComputerName server2 -Credential $cred
So, gather the credential first, then just plug it in. And, you can literally use localhost for the domain side and that works. Worked for me.
> $session
Id Name ComputerName State ConfigurationName Availability
-- ---- ------------ ----- ----------------- ------------
1 Session1 server2 Opened Microsoft.PowerShell Available
User contributions licensed under CC BY-SA 3.0