I want to connect two windows server on different domains using powershell remoting.

Abhishek Goyal 21 Reputation points
2022-12-30T10:49:20.963+00:00

I follows step that given in below blog https://activedirectoryfaq.com/2018/09/import-powershell-sessions-from-computers-in-another-domain/ but it did not work for me. By following this blog, on connection it gives ** Enter-PSSession : Connecting to remote server failed with the following error message : WinRM cannot process the request. The following error occurred while using Kerberos authentication: Cannot find the computer . Verify that the computer exists on the network and that the name provided is spelled correctly. For more information, see the about_Remote_Troubleshooting Help topic **

client server is windows server 2022 machine (powershell version 5.1.20348.1366) remote server is windows server 2016 machine (powershell version 5.1.14393.1480)

Help me with it.

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
4,628 questions
No comments
{count} votes

Accepted answer
  1. MotoX80 23,651 Reputation points
    2022-12-31T15:35:52.44+00:00

    Use a local account.

    On the client add the name of the server to trusted hosts.

    Set-Item WSMan:\localhost\Client\TrustedHosts -Value 'TheServerName'  
    

    Then connect like this example.

        $sb = {  
            $admin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")  
            "Running on {0}" -f $env:COMPUTERNAME  
            "Your name is {0}" -f  $env:USERNAME   
            "Admin level is {0}" -f  $admin  
        }  
          
        $User = ".\admin"  
        $PWord = ConvertTo-SecureString -String "admin" -AsPlainText -Force  
        $Credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $User, $PWord  
        Invoke-Command -ComputerName TheServerName -ScriptBlock $sb -Credential $Credential   
          
    

0 additional answers

Sort by: Most helpful