Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fortran01/85573ae082b8d8b4703537fdd3b2bb25 to your computer and use it in GitHub Desktop.
Save fortran01/85573ae082b8d8b4703537fdd3b2bb25 to your computer and use it in GitHub Desktop.

If the source computer (the one initiating the WinRM access) is not domain-joined, but the target computer is domain-joined, you can still use WinRM to access the target computer with domain credentials.

In this scenario, you need to ensure that the following configurations are in place:

  1. Make sure WinRM service is enabled and running on the target computer. On the target computer, open an elevated PowerShell prompt and run:
Enable-PSRemoting -Force
  1. If the target computer is running a Windows firewall or another type of firewall, you need to allow incoming connections on TCP port 5985 (default port for WinRM). You can do this using the following command in an elevated PowerShell prompt on the target computer:
Set-NetFirewallRule -Name WINRM-HTTP-In-TCP -RemoteAddress Any
  1. Configure the target computer's TrustedHosts list to include the source computer's name or IP address. This can be done using the following command in an elevated PowerShell prompt on the target computer:
Set-Item WSMan:\localhost\Client\TrustedHosts -Value 'SourceComputerNameOrIP'

Replace 'SourceComputerNameOrIP' with the actual source computer's name or IP address.

After completing these configurations, you can use WinRM on the source computer to access the target computer by specifying the domain account in the DOMAIN\Username format.

For example, if you are using PowerShell to initiate a remote session, the command would look like this:

Enter-PSSession -ComputerName TargetComputerName -Credential DOMAIN\Username

Replace 'TargetComputerName' with the actual target computer's name and 'DOMAIN\Username' with the domain account you want to use.

Remember that using TrustedHosts and non-domain joined computers is less secure than using domain-joined computers with proper authentication and encryption. It's recommended to use domain-joined computers whenever possible for a more secure and manageable environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment