Learning and Sharing
  • Home
  • Blog
  • Linux
  • macOS
  • Virtualization
    • VMware
    • VirtualBox
  • Windows
    • Windows 11
    • Windows 10
    • Windows Server
  • Series
    • Symantec
    • Intune
    • Microsoft Azure
    • Powershell
    • VirtualBox
    • VMware
    • PowerShell Learning
    • Microsoft Graph
  • More
    • Auto Installation
    • AEC Installation
  • Contact
No Result
View All Result
  • Home
  • Blog
  • Linux
  • macOS
  • Virtualization
    • VMware
    • VirtualBox
  • Windows
    • Windows 11
    • Windows 10
    • Windows Server
  • Series
    • Symantec
    • Intune
    • Microsoft Azure
    • Powershell
    • VirtualBox
    • VMware
    • PowerShell Learning
    • Microsoft Graph
  • More
    • Auto Installation
    • AEC Installation
  • Contact
No Result
View All Result
No Result
View All Result

How to Enable PowerShell Remoting using Group Policy

June 18, 2024
in Blog, Group Policy, PowerShell Remoting
0
ADVERTISEMENT

Table of Contents

Default PSRemoting Settings on Windows

Since PSRemoting was born in Windows, it comes enabled by default but not universally and also not for all Windows OS versions.

On Windows Server, PSRemoting is enabled sometimes but not all of the time depending on what network profile Windows is running under. Below you’ll find a handy table to help you determine if your Windows OS has PSremoting enabled or not.

Note Note: On all Windows client operating systems, PSRemoting is always disabled.
Operating SystemNetwork ProfilePSRemoting
Windows 7, 8, 10, 11Domain/Private/PublicDisabled
Windows Server 2008 R2Domain/Private/PublicDisabled
Windows Server 2012 & NewerDomain/PrivateEnabled
Windows Server 2012 & NewerPublicEnabled within the same subnet

Enabling PowerShell remoting in a domain (single computer)

Windows PowerShell remoting is infinitely easier to configure in a domain environment because all domain member computers trust each other implicitly.

PS C:\Windows\system32> Get-NetConnectionProfile

Name                     : duybao.me
InterfaceAlias           : Ethernet0
InterfaceIndex           : 12
NetworkCategory          : DomainAuthenticated
DomainAuthenticationKind : Ldap
IPv4Connectivity         : Internet
IPv6Connectivity         : NoTraffic

Thus, turning on PowerShell remoting on a Windows client or server computer is simply a matter of opening an elevated PowerShell console session and issuing the following statement:

Enable-PSRemoting -Force

The -Force parameter is technically optional, but I recommend that you use it; otherwise, you’ll be stuck passing through confirmation prompts.

PS C:\Windows\System32> 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.

The Enable-PSRemoting command makes the following changes to your system:

  • Starts the Windows Remote Management (WinRM) service and sets it for automatic startup
  • Creates a listener to accept remote requests on any IP address
  • Enables a firewall exception for WS-Management
  • Makes some additional under-the-hood changes to support PowerShell remoting sessions and workflows

You might wonder what the difference is between Enable-PSRemoting and, say, winrm quickconfig. Technically speaking, not much. In fact, running Enable-PSRemoting performs all the work of winrm quickconfig but includes additional Windows PowerShell-specific environment changes. Long story short: If you run Enable-PSRemoting, you don’t need to run winrm quickconfig.

PS C:\Windows\System32> winrm quickconfig -quiet
WinRM is not set up to receive requests on this machine.
The following changes must be made:

Start the WinRM service.
Set the WinRM service type to delayed auto start.

WinRM has been updated to receive requests.

WinRM service type changed successfully.
WinRM service started.
WinRM is not set up to allow remote access to this machine for management.
The following changes must be made:

Enable the WinRM firewall exception.
Configure LocalAccountTokenFilterPolicy to grant administrative rights remotely to local users.

WinRM has been updated for remote management.

WinRM firewall exception enabled.
Configured LocalAccountTokenFilterPolicy to grant administrative rights remotely to local users.

How do you know is has been enabled? Run a test command such as the following command, which creates a remote session on the local computer. If remoting is configured correctly, the command creates a session on the local computer and returns an object that represents the session.

PS C:\Windows\System32> New-PSSession

 Id Name            ComputerName    ComputerType    State         ConfigurationName     Availability
 -- ----            ------------    ------------    -----         -----------------     ------------
  1 WinRM1          localhost       RemoteMachine   Opened        Microsoft.PowerShell     Available

Enable PSRemoting Using Group Policy

The best option for enabling WinRM across a wide range of computers is through group policy. When using Group Policy, you can create a single Group Policy Object and apply that policy across thousands of computers at once.

To use Group Policy to enable WinRM across many computers at once, you’re going to need to set three different configuration items:

  • Enable the WinRM service.
  • Open the Windows Firewall port for WinRm.
  • Creating the WinRM listener and allow connections to it.

Enabling the WinRM Service

1️⃣ First, RDP to a domain controller or, better yet, install the remote server administrator tools (RSAT) package on a domain-joined workstation. You should now have the Group Policy Management Console (GPMC) available.

2️⃣ Enable the WinRM service on all target computers by Open up the GPMC and create a GPO. We recommand you create a separate OU for the computers that you want to enable PSRemoting. Instead of editing the Default Domain Policy.

dgL5ZNQ7Jxrmwj8cTWBw0CDPrRpq6oo8dt5q2UcWQvhPqREd1GmRyXkRqXXN

3️⃣ When editing the GPO, navigate to Computer Configuration —> Windows Settings —> Security Settings —> System Services. 

4️⃣ Double click on Windows Remote Management (WS-Management) to configure it.

uubrOCOyZCF62l6NEy5dHa7QMe6vuXnDUIGD1P0Y9urGMnnM3m1tgIAeCM87

5️⃣ In the configuration panel check the box for Define this policy setting. Select the radio button for Automatic to set the WinRm service to start automatically on boot. Click OK to confirm the setting.

spdHtIsXhme3ZRFohghqmZ0QIGWCTtHHGZi4tk34vIUeAEXg3IkyncFLJAJ1

Opening the Windows Firewall Port

Next, you need to open the WinRM port on all of the target computers. While still editing the GPO created above:

1️⃣ Navigate to Computer Configuration —> Windows Settings —> Security Settings —> Windows Defender Firewall with Advanced Security.

2️⃣ Click on the New Inbound Rule to create a new inbound rule.

VzyfMjKLr1CEzgHJiESazLr5D7IjDt9o4P4xFNjhJjnNcP3mRqwjymjq6mPJ

3️⃣ On the first page select Predefined and select Windows Remote Management as shown below.

FtzHssuBYkTCeYMSNVgU48fLTXpOnKRopiDhdbUeXCIqittD8vzVmWQK78My

4️⃣ On the next page, check the box for the Domain/Private network rule unless you know that Public networks are used in your environments and you will need to allow remote connections from them.

cjAkBs6ZxqKt8iJRsBUgv4Ma3Ov5P75tutB2wyz8MlnltxHVGO9y0TAmvh0A

5️⃣ On the next page leave the default of Allow the connection and click Finish to create the rule.

Create the WinRM Listener and Filter List

The final configuration item to add to your GPO is creating the WinRM listener ad allowing connections to that WinRM listener. This setting creates the WinRM listener for HTTP and allows connections to it from the specified IPs or IP ranges.

While still editing the WinRM GPO:

1️⃣ Navigate to Computer Configuration —> Administrative Templates —> Windows Components —> Windows Remote Management (WinRM) —> WinRM Service.

w88JUqoNUbltCvI0RaWUvL11Hwjy57qFvSLeOLqNQsG6vQemywKnMazagVEy

2️⃣ Select Enabled for the setting Allow remote service management through WinRM. Under the Allow remote server management through WinRM setting, provide an asterisk (*) for both the IPv4 filter and IPv6 filter as shown below.

Note Note: Notice that you can specify multiple hosts separated by a comma in each filter list if you know ahead of time which hosts will be connecting to all target computers.
AdS8AludqDHGb5Qsq0igrFtmtQcwqYOy0kwDvTypdveixsjMlSLwPh1r7hvk

3️⃣ Click OK to confirm the newest GPO setting.

Applying the GPO

On client computers, this is done by default every 90 minutes, with a randomized offset of plus or minus 30 minutes. Admin can force it using gpupdate /force command to take the changes immediately.

PS C:\Users\admin.DUYBAO> Get-WSManInstance winrm/config/listener -Enumerate

cfg                   : http://schemas.microsoft.com/wbem/wsman/1/config/listener
xsi                   : http://www.w3.org/2001/XMLSchema-instance
Source                : GPO
lang                  : en-US
Address               : *
Transport             : HTTP
Port                  : 5985
Hostname              :
Enabled               : true
URLPrefix             : wsman
CertificateThumbprint :
ListeningOn           : {10.10.18.111, 127.0.0.1, ::1, fe80::4010:cb41:c00b:30b6%11}

Testing Remote Access

On the local computer, make sure that the remote computer now accepts remote connections via PSRemoting. This is optional step, but it could help for troubleshooting.

PS C:\Users\Administrator> Test-NetConnection HR-PC001 -Port 5985

ComputerName     : HR-PC001
RemoteAddress    : 10.10.18.111
RemotePort       : 5985
InterfaceAlias   : Ethernet0
SourceAddress    : 10.10.19.22
TcpTestSucceeded : True

PS C:\Users\Administrator> Test-WSMan HR-PC001

wsmid           : http://schemas.dmtf.org/wbem/wsman/identity/1/wsmanidentity.xsd
ProtocolVersion : http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd
ProductVendor   : Microsoft Corporation
ProductVersion  : OS: 0.0.0 SP: 0.0 Stack: 3.0

Because we’re in a domain environment, we don’t need to enter username and password for PSRemoting. PowerShell will user the current log on credentials.

PS C:\Users\Administrator> Enter-PSSession -ComputerName HR-PC001
[HR-PC001]: PS C:\Users\Administrator\Documents> hostname
HR-PC001

If you want to remote PowerShell using different credential, you can put it into the Enter-PSSession command. For example, we’ll create a remote session with Chris’s account:

PS C:\Users\Administrator> Enter-PSSession -ComputerName HR-PC001 -Credential duybao\chris
[HR-PC001]: PS C:\Users\chris\Documents> whoami
duybao\chris

Alternatively, if you don’t want to create a full session to the remote computer. you can execute commands and scripts on remote workgroup computers using the Invoke-Command. For example, restart a computer remotely:

Invoke-Command -ComputerName HR-PC001 –ScriptBlock {
    Restart-Computer
}

Use the -Credential parameter in all remote commands. This is required even when you connect as the current user. If you don’t want to type the password every command, you can create a variable as follows:

PS C:\> $cred = Get-Credential
cmdlet Get-Credential at command pipeline position 1
Supply values for the following parameters:
Credential

PS C:\> Invoke-Command -ComputerName HR-PC001 -Credential $cred -ScriptBlock {
    Restart-Computer
}

Install application remotely using PSRemoting

Once the computers can be managed using PSRemoting, we can install applications on these clients remotely. For example, we’ll install Zoom Client app on IT-PC001.

  • Copy the installer from file server to the admin share of the client.
  • Run the remote command on the client with Invoke-Command cmdlet.
$file = "\\fileserver\dataroom\public\zoom.msi"
Copy-Item -Path $file -Destination "\\IT-PC001\C$\Windows\Temp\zoom.msi" -Force
Invoke-Command -ComputerName 'IT-PC001' -ScriptBlock {
    Start-Process -FilePath 'msiexec.exe' -ArgumentList "/i C:\Windows\Temp\zoom.msi /qn" -Wait
}

If you want to install an app on multiple devices, you can use the below script:

$file = "\\fileserver\dataroom\public\zoom.msi"
$computers = @('IT-PC001','HR-PC001','HR-PC002')

foreach ($computer in $computers) {
    Copy-Item -Path $file -Destination "\\$computer\C$\Windows\Temp\zoom.msi"
    Invoke-Command -ComputerName $computer -ScriptBlock {
        Start-Process -FilePath 'msiexec.exe' -ArgumentList "/i C:\Windows\Temp\zoom.msi /qn" -Wait
    }
}  

Enabling PowerShell remoting in a workgroup

When your computers exist outside of an Active Directory domain, PowerShell remoting is certainly possible, but it is quite a bit more tedious to set up. One approach involves the use of digital certificates; the other, which we’ll use here, implements the TrustedHosts list.

Read more: How to Enable PowerShell Remoting on Workgroup Computers

ADVERTISEMENT

Not a reader? Watch this related video tutorial:

5/5 - (1 vote)
Previous Post

Enable PowerShell Remoting on Windows 10/11 with Public Networks

Next Post

Network Profile is Showing as Private Instead of DomainAuthenticated in Domain Controller

Related Posts

Running Hyper-V and VMware Workstation on The Same Machine

August 15, 2024

How to Uninstall All Autodesk Products At Once Silently

July 29, 2024
Ftr5

How to Uninstall the Autodesk Genuine Service on Windows

July 29, 2024
Ftr19

How to Fix Windows Cannot Read the ProductKey From the Unattend Answer File in VirtualBox

July 26, 2024
Ftr25

How to Update Windows Terminal in Windows 10/11

July 26, 2024

How to Disable The Beep Sound in WSL Terminal on Windows

July 26, 2024

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts

  • How To Turn On uBlock Origin Extension in Chrome (2025)
  • Images Hidden Due To Mature Content Settings In CivitAI
  • Azure OpenAI vs Azure AI Hub, How to Choose the Right One for Your Needs

Categories

Stay in Touch

Discord Server

Join the Discord server with the site members for all questions and discussions.

Telegram Community

Jump in Telegram server. Ask questions and discuss everything with the site members.

Youtube Channel

Watch more videos, learning and sharing with Leo ❤❤❤. Sharing to be better.

Newsletter

Join the movement and receive our weekly Tech related newsletter. It’s Free.

General

Microsoft Windows

Microsoft Office

VMware

VirtualBox

Technology

PowerShell

Microsoft 365

Microsoft Teams

Email Servers

Copyright 2025 © All rights Reserved. Design by Leo with ❤

No Result
View All Result
  • Home
  • Linux
  • Intune
  • macOS
  • VMware
  • VirtualBox
  • Powershell
  • Windows 10
  • Windows 11
  • Microsoft 365
  • Microsoft Azure
  • Microsoft Office
  • Active Directory

No Result
View All Result
  • Home
  • Linux
  • Intune
  • macOS
  • VMware
  • VirtualBox
  • Powershell
  • Windows 10
  • Windows 11
  • Microsoft 365
  • Microsoft Azure
  • Microsoft Office
  • Active Directory