This self-answered question, which focuses on Windows[1], addresses the following aspects:
Now that there are two PowerShell editions - the legacy, Windows-only Windows PowerShell and the cross-platform PowerShell Core, both may be installed on a given Windows machine:
How can I tell which PowerShell edition will execute remote commands, such as via
Invoke-Command -ComputerName
?How can I target a specific edition, both ad hoc and persistently, through configuration?
Note:
For an edition to be targetable via remoting on a given machine, it must be set up for remoting:
Only Windows PowerShell is automatically set up for remoting, but only on servers running Windows Server 2012 or higher.
As of v7, PowerShell Core doesn't come with Windows yet; if you're using the official installer, you're given the option of enabling remoting during the installation.
In any event, you can use Enable-PSRemoting
to (re-)enable PowerShell remoting on demand, which:
must be run from the respective edition.
must be run with administrative privileges
[1] That is, the question focuses on WinRM-based remoting (WinRM is a Windows-specific implementation of the DTMF WSMan (WS-Management) standard).
As for cross-platform remoting with PowerShell Core:
You can already use SSH-based remoting, on all platforms:
Using SSH-based remoting involves mostly the same cmdlets as WinRM-based remoting, though the parameters involved differ; most notably, you specify the target computer(s) via the
-HostName
parameter rather than the-ComputerName
parameter.Limitations (as of v7): "SSH-based remoting doesn't currently support remote endpoint configuration and Just Enough Administration (JEA)."
For Unix-to-Windows remoting (Unix referring to Unix-like platforms such as macOS and Linux) - that is, remoting into a Windows machine from a Unix-like machine - you can alternatively use WinRM-based remoting with additional configuration:
On the Windows machine:
- SSL connections must be enabled by configuring WinRM for HTTPS.
- The user accounts to be used from the Unix-like machines must be defined as local user accounts in the local Administrators group - domain accounts won't work.
The Unix-like machines must use the remoting cmdlets with the
-Authentication Basic -UseSsl
parameters.
A Unix WSMan-based implementation is being worked on in the psl-omi-provider repository, which already enables Linux machines to act as remoting targets (that is, the server component is already usable - it's not clear to me whether it can also be installed on macOS); the client component, however, is not yet production-ready as of this writing.
Once the client client component is available, uniform WSMan-based cross-platform remoting will be possible, both between Unix-like machines (Linux, macOS) and between Unix-like machines and Windows machines.