PowerShell Remoting
Remoting is enabled by default on server 2012 and later only
To enable it on earlier servers and desktops you can use Enable-PSRemoting
if you want to do this to multiple computers or servers you can use group policy
Go to group policy management editor and go to:
computer configuration > policies > administrative templates > windows components > Windows Remote Management > WinRM service
Edit "Allow remote server management through WinRm" select enabled and specify your ip addressing subnets required following the example provided
This will allow PowerShell management of any of the computers in scope.
You also need to configure a windows firewall exception go to :
Administrative templates > network > network connections > windows defender firewall > domain profile
Open "Windows Defender Firewall: Allow local port exception" and set that to enabled then
Open "Windows Defender Firewall: Define inbound port exceptions" at the same location and add inbound port exception 5985 for http
this should look somthing like 5985:http:192.168.1.0/24:enable:powershellRemoting there are examples in the group policy
You also need to make winrm startup automatically
Connecting to machine using PoweShell Remoting
There are 2 main ways of using this Directly Enter-PSSession and Invoke-Command
Enter-PSSession is like logging on with SSH is the unix world
One you have connected this way it is like you opened an RDP session to the computer and opened powershell
When you have remoted into another server the cursser changes to [computer.company.pri]: PS C:\
Implicit Remoting
Implicit remoting allows you to connect to PowerShell modules on other machines and run them like they are installed on the local machine.
This example connects to a DC and runs the AD module on the local machine.
$cred = Get-Credential -Credential $dcSession = New-PSSession -ComputerName '10.0.0.11' -Credential $cred Import-PSSession -Session $dcSession -Prefix PDT -Module activedirectory