Windows OS Hub
  • Windows
    • Windows 11
    • Windows Server 2022
    • Windows 10
    • Windows Server 2019
    • Windows Server 2016
  • Microsoft
    • Active Directory (AD DS)
    • Group Policies (GPOs)
    • Exchange Server
    • Azure and Microsoft 365
    • Microsoft Office
  • Virtualization
    • VMware
    • Hyper-V
  • PowerShell
  • Linux
  • Home
  • About

Windows OS Hub

  • Windows
    • Windows 11
    • Windows Server 2022
    • Windows 10
    • Windows Server 2019
    • Windows Server 2016
  • Microsoft
    • Active Directory (AD DS)
    • Group Policies (GPOs)
    • Exchange Server
    • Azure and Microsoft 365
    • Microsoft Office
  • Virtualization
    • VMware
    • Hyper-V
  • PowerShell
  • Linux

 Windows OS Hub / PowerShell / Configure PowerShell Remoting (WinRM) for Non-Domain (Workgroup) Computers

March 15, 2024

Configure PowerShell Remoting (WinRM) for Non-Domain (Workgroup) Computers

PowerShell Remoting is a great tool that allows you to connect and run commands on remote computers via WinRM. If computers are joined to the Active Directory domain, then PSRemoting uses Kerberos to authenticate to remote hosts. However, if your computers are in a workgroup, you will have to use NTLM (TrustedHosts) or SSL certificates for authentication. Let’s look at how to configure and use PSRemoting (WinRM) in a Workgroup (Non-Domain) environment.

In this example, there are two hosts in a Windows workgroup:

  • Administrator workstation — 192.168.13.100
  • User’s computer — 192.168.13.222

Our task is to connect to the user’s computer remotely via PowerShell Remoting.

The first step is to enable and configure WinRM on the remote host. You will have to enable WinRM locally or remotely (for example, using RDP, psexec, or GPO).

Make sure that the WinRM service is running on the target user’s computer:

Get-Service -Name "*WinRM*" | select status

If the service is not running, enable it:

Enable-PSRemoting

WinRM has been updated to receive requests.
WinRM service type changed successfully.
WinRM service started.
WinRM has been updated for remote management.
WinRM firewall exception enabled.
Configured LocalAccountTokenFilterPolicy to grant administrative rights remotely to local users.

enable psremoting (winrm) on a workgroup computer

As you can see, the LocalAccountTokenFilterPolicy UAC option is automatically enabled to allow remote access under administrator accounts.

If the Public type of network connection is set on a computer, you will see the following error when enabling WinRM:

Set-WSManQuickConfig : ... WinRM firewall exception will not work since one of the network connection types on this machine is set to Public. Change the network connection type to either Domain or Private and try again.

Change the network type to Private (Set-NetConnectionProfile -NetworkCategory Private) or run the command below:

Enable-PSRemoting –SkipNetworkProfileCheck

Open the port TCP/5985 in Windows Defender Firewall to connect to WinRM. The easiest way is to open a Windows Firewall port using PowerShell. In this example, we will open the remote access only for the IP address of the administrator’s computer (more secure), but you can open it for everyone (specify Any instead of an IP address):

Set-NetFirewallRule -DisplayName "Windows Remote Management (HTTP-In)" -RemoteAddress 192.168.13.100
Enable-NetFirewallRule -DisplayName "Windows Remote Management (HTTP-In)"

On the administrator computer, make sure that the user’s computer now accepts remote connections via PSRemoting:

Test-NetConnection 192.168.13.222 –Port 5985
Test-WsMan 192.168.13.222

Test-WsMan - test WinRM connectivity via PowerShell

However, if you try to connect to a user computer remotely using the Invoke-Command or Enter-PSSession cmdlets, the following error appears:

Enter-PSSession 192.168.13.222

Enter-PSSession : Connecting to remote server 192.168.13.222 failed with the following error message: The WinRM client cannot process the request. If the authentication scheme is different from Kerberos, or if the client computer is not joined to a domain, then HTTPS transport must be used or the destination machine must be added to the TrustedHosts configuration setting. Use winrm.cmd to configure TrustedHosts. Note that computers in the TrustedHosts list might not be authenticated. PSRemotingTransportException.

The WinRM HTTP Listener on the remote computer only allows connection with Kerberos authentication.

Get-ChildItem -Path WSMan:\localhost\Service\Auth\

WSMan authentication types - kerberos and negotiate

In order to use Negotiate authentication with NTLM, your computer must trust the remote computer. In a domain, this is achieved using Kerberos, while in a workgroup environment, you’ll have to add the computer’s IP addresses to TrustedHosts.

Add a user computer to TrustedHosts on the administrator’s computer (you can do it using its IP address or FQDN):

Set-Item wsman:\localhost\client\TrustedHosts -Value 192.168.13.222 -Force

List computers in TrustedHosts:

get-Item WSMan:\localhost\Client\TrustedHosts

To clear the TrustedHosts list:

Set-Item WSMan:\localhost\Client\TrustedHosts -Value "" –Force

To add a new computer to the TrustedHosts list, use the -Concatenate option:

Set-Item WSMan:\localhost\Client\TrustedHosts -Value 192.168.13.200 -Concatenate

You can also allow remote connection to all computers (usually, it is not recommended as one of the major disadvantages of NTLM authentication is vulnerable to various malicious attacks).

Set-Item wsman:\localhost\Client\TrustedHosts -value *

Then try to connect to the remote computer over PSRemoting:

Enter-PSSession -ComputerName 192.168.13.222 -Credential 192.168.13.222\root

Enter the remote computer’s administrator password and make sure that the connection has been established successfully (the hostname or the IP address of the remote computer is displayed in the PowerShell prompt).

enter-pssession on a workgroup computer

Now you can execute commands and scripts on remote workgroup computers using the Invoke-Command. For example, restart a computer remotely:

Invoke-Command -ComputerName 192.168.13.222 -Credential 192.168.13.222\root –ScriptBlock {Restart-Computer}

Or run a PowerShell script:

Invoke-Command -ComputerName 192.168.13.222 -Credential 192.168.13.222\root -FilePath c:\Scripts\GetComputerInfo.ps1

In WinRM, you can also use HTTPS to connect to remote computers. To do it, you need to issue an SSL certificate on a remote computer and import it to the administrator’s computer. In this case, you don’t need to add the remote computer IP address to the TrustedHosts list. Learn more about how to configure PowerShell Remoting (WinRM) over HTTPS.

Note that to authenticate on a remote computer, you must enter a user password using the –Credential option. If you have many computers in your network with different local admin passwords, it is convenient to store connection passwords in a vault. It may be either a Windows Credential Manager password vault or an external store, like KeePass, LastPass, HashiCorp Vault, Azure Key Vault, or Bitwarden.

You can use the PowerShell Secret Management module to access saved passwords in such a vault. Now, in order to connect to a remote computer via PSRemoting, it is enough to:

  1. Save a connection password, for example, to Credential Manager: cmdkey /add:192.168.13.222 /user:root /pass:Password1
  2. Get the name and the password from the vault using the CredentialManager module: $psCred = Get-StoredCredential -Target "192.168.13.222"
  3. Connect to the remote computer using PSRemoting and the saved password: Enter-PSSession -ComputerName 192.168.13.222 -Credential $psCred
If you store passwords in another vault type, use Microsoft.PowerShell.SecretManagement module to get the saved credentials.

In new PowerShell Core versions (v6 or v7), you can use the Secure Shell (SSH) protocol to connect to a remote computer via PowerShell Remoting. To do this, the built-in SSH server must be enabled in Windows.

The -HostName (instead of –ComputerName) and -UserName (instead of -Credential) options allow to set the computer name and user for the SSH connection
Enter-PSSession -HostName 192.168.50.20 -UserName maxbak

You can even authenticate to Windows using an SSH key (use the  –KeyFilePath parameter to specify the path to the private SSH key):

Enter-PSSession -HostName [email protected]:22 -KeyFilePath c:\PS\your_rsa_key

By default, WinRM allows remote connection to administrators only. However, you can allow remote access using PSRemoting for non-admin users.
3 comments
4
Facebook Twitter Google + Pinterest
PowerShellWindows 10Windows Server 2019
previous post
How to Run Multiple Commands in One Line in PowerShell and CMD
next post
Fix: Group Policy Processing Error in Windows

Related Reading

Fix: Remote Desktop Licensing Mode is not Configured

August 24, 2023

Wi-Fi (Internet) Disconnects After Sleep or Hibernation on...

March 15, 2024

How to Install Remote Server Administration Tools (RSAT)...

March 17, 2024

How to Find the Source of Account Lockouts...

March 12, 2024

How to Delete Old User Profiles in Windows

March 15, 2024

Install and Manage Windows Updates with PowerShell (PSWindowsUpdate)

March 17, 2024

How to Backup and Restore Websites and IIS...

June 8, 2023

Start Menu or Taskbar Search Not Working in...

April 22, 2025

3 comments

Savas July 11, 2023 - 5:37 pm

Excellent article. It’s critical to get the trusted hosts list set up properly and also the firewall config to open the port at the receiver.
This saved me a ton of work, thanks again!

Reply
Zinna November 24, 2023 - 9:07 pm

Great guide!!
Thank you

Reply
Abid Hussain November 5, 2024 - 10:03 am

Excellent articale.

Reply

Leave a Comment Cancel Reply

join us telegram channel https://t.me/woshub
Join WindowsHub Telegram channel to get the latest updates!

Recent Posts

  • Configuring Windows Protected Print Mode (WPP)

    May 19, 2025
  • Map a Network Drive over SSH (SSHFS) in Windows

    May 13, 2025
  • Configure NTP Time Source for Active Directory Domain

    May 6, 2025
  • Cannot Install Network Adapter Drivers on Windows Server

    April 29, 2025
  • Change BIOS from Legacy to UEFI without Reinstalling Windows

    April 21, 2025
  • How to Prefer IPv4 over IPv6 in Windows Networks

    April 9, 2025
  • Load Drivers from WinPE or Recovery CMD

    March 26, 2025
  • How to Block Common (Weak) Passwords in Active Directory

    March 25, 2025
  • Fix: The referenced assembly could not be found error (0x80073701) on Windows

    March 17, 2025
  • Exclude a Specific User or Computer from Group Policy

    March 12, 2025

Follow us

  • Facebook
  • Twitter
  • Telegram
Popular Posts
  • Install and Manage Windows Updates with PowerShell (PSWindowsUpdate)
  • How to Download Offline Installer (APPX/MSIX) for Microsoft Store App
  • How to Delete Old User Profiles in Windows
  • Fix: Remote Desktop Licensing Mode is not Configured
  • How to Install Remote Server Administration Tools (RSAT) on Windows
  • Configuring Port Forwarding in Windows
  • Get-ADUser: Find Active Directory User Info with PowerShell
Footer Logo

@2014 - 2024 - Windows OS Hub. All about operating systems for sysadmins


Back To Top