6.1 - PowerShell Remoting & Tradecraft
PowerShell Remoting
PowerShell Remoting (PSRemoting) is a powerful tool for remote administration, often compared to PsExec but more efficient, stealthy, and faster. It utilizes Windows Remote Management (WinRM), Microsoft's implementation of the WS-Management protocol.
Enabled by default on Windows Server 2012+ with firewall exceptions.
Listens on port 5985 (HTTP) and 5986 (HTTPS).
Recommended for managing Windows Core servers.
Requires Enable-PSRemoting on Windows desktops (admin privileges needed).
Runs with high integrity, providing an elevated shell by default.
PSSession
This mode establishes an interactive session with only one remote system.
🔹 Key Features:
Runs in a new process (
wsmprovhost).Maintains session state.
🔹 Useful Cmdlets:
New-PSSession– Creates a new session.Enter-PSSession– Interacts with a remote session.
Example of usage:

Invoke-Command
This method executes commands across multiple systems simultaneously.
🔹 Key Features:
Non-interactive execution.
Runs commands in parallel.
🔹 Useful Cmdlet:
Invoke-Command– Executes commands across multiple machines.
Useful Commands
Run a command remotely:
Execute a script from a file:
Run a locally defined function on remote machines:
Pass arguments to a remote function (only positional arguments allowed):
Maintain a stateful session:
Example of usage:



Tradecraft
PowerShell Remoting supports system-wide transcripts and script block logging, making activities traceable. However, alternatives like winrs can evade some logging mechanisms while still leveraging port 5985.
Using
winrsto execute commands remotely:

Using
winrm.vbsand COM objects for WSMan: Refer to: GitHub - WSMan-WinRM
Labs
Refers to Learning Object 7 lab
Last updated