When I remote desktop to a box I will get a prompt like this:
Once I select "Yes" I am connected to the box. When I try to login to the same box with the same credentials in PowerShell I get the error listed at the end of this post.
$secPasswd = ConvertTo-SecureString $password -AsPlainText -Force
$creds = New-Object System.Management.Automation.PSCredential($username, $secPasswd)
$session = New-PSSession –ComputerName $hst -Credential $creds
where $hst is "MyBox" and $username is "MyBox\MyUser"
Q: Is there a way in powershell for me to mimic the selection of the "Yes" button?
ERROR:
New-PSSession : [MyBox] Connecting to remote server MyBox 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.
Analysis on target box
WinRM is running
Expected firewall rules are in place
User is part of the admin group
PSRemoting is enabled
User contributions licensed under CC BY-SA 3.0