So first off, let's understand PowerShell remoting.
Well, firstly,
PowerShell remoting isn't the same as using the cmdlet's
ComputerName parameter to run it on a remote computer.
That is not the same.
Using that ComputerName,
it's just an option to connect to a machine that's
already got everything enabled.
PowerShell remoting is physically connecting to that
machine or choosing to connect to the machine and then
passing commands through the session.
Now PowerShell remoting itself,
it's a protocol that allows users to run PowerShell
commands directly on those remote computers.
PowerShell supports remote computing by using various technologies.
PowerShell supports the use of the WMI, the WS‑Management,
and also SSH remoting,
and PowerShell 7 and above supports RPC remoting only when you're using Windows.
Now in order for us to know how this works,
we first need to understand what this is,
WinRM.
WinRM is Windows Remote Management,
and it's Microsoft's implementation of what's called the WS‑Management protocol.
WS‑Man is the standard Simple Object Access Protocol,
or SOAP protocol,
that allows hardware and the operating system from
different vendors to interoperate together.
PowerShell remoting is primarily designed for connecting and
managing remote devices within an Active Directory or what you
would class as a corporate environment.
Now there are a couple different options of connecting.
The first one would be HTTP.
This is the Windows 10 default option or Windows 10 and higher I should say.
Then we have HTTPS.
This one does require IT to acquire, provision, and manage
certificates for this type of connection.
And then, of course, we have SSH, which has been available since PowerShell Core,
and this is a cross‑platform connection.
So it means that we can go from Windows to Windows,
Windows to Linux, Linux to Mac, Mac to Windows,
etc.
So it's a truly cross‑platform connection.
In order for us to use PowerShell remoting, we first need to connect.
Then we can authenticate.
Then we can execute the commands that will be sent down that connection.
And then any of the output is returned back via that remote session.
Now to enable PowerShell remoting we can do it using WS‑MAN.
The first option here is to enable it for non‑administrators,
which you would define an Active Directory security group
for this, and then you would add group to the remote
management users' group locally.
The other option is we can utilize Group Policy for enabling
it on multiple machines. We would use the computer
configuration option in the Group Policy,
navigate to the Windows Remote Management settings, and then
simply set the allow option for the WinRM service.
So how do we enable PowerShell remoting using PowerShell?
Well to enable it over HTTP, we can use
Set‑WSManQuickConfig. If I want to use HTTPS,
I can say UseSSL. And if I want to simply just enable PSRemoting on
a machine, I can just call Enable‑PSRemoting. I can also go through
and skip the network check profile,
which can sometimes cause a problem, and we can simply say
Enable‑PSRemoting, force it, and then skip the profile check.