liveBook · Manning

Implicit remoting

As explained in Learn PowerShell in a Month of Lunches: Fourth Edition, Covers Windows, Linux, and macOS

Implicit remoting is a PowerShell technique that exposes commands from a remote session as local proxy commands while executing them on the remote computer.

Implicit remoting reduces repeated computer names, credentials, ports, and authentication settings by keeping a remote session open and exposing its commands locally. section 18.0

Use the technique in a short sequence:

  • Create a PSSession with the remote computer. section 18.4
  • Import the desired module into that remote session. section 18.4
  • Import the session’s commands with an optional prefix, creating local shortcuts that execute remotely. section 18.4
PS C:\> $session = new-pssession -comp SRV02                                   #1
PS C:\> invoke-command -command { import-module activedirectory }              #2
        session $session
PS C:\> import-pssession -session $session -module activedirectory -prefix rem #3
 
ModuleType Name                      ExportedCommands                          #4
---------- ----                      ----------------
Script     tmp_2b9451dc-b973-495d... {Set-ADOrganizationalUnit, Get-ADD...

This command sequence imports the Active Directory module from SRV02 and exposes its commands locally with the rem prefix. section 18.4

How Learn PowerShell in a Month of Lunches: Fourth Edition, Covers Windows, Linux, and macOS covers it

How deep it goes
Explains session import, module loading, prefixes, temporary modules, and remote shortcuts.
Examples
Demonstrates importing the Active Directory module from SRV02 with the rem command prefix.
What it assumes
Assumes another computer, an enabled PowerShell remoting configuration, and a remotely available module.
What you can do after
Operate remote Active Directory commands locally while the associated PSSession remains open.
How it connects
Connects remoting with reusable sessions, PowerShell modules, proxy commands, and Active Directory.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn PowerShell in a Month of Lunches: Fourth Edition, Covers Windows, Linux, and macOS. The section links point to the parts of the book it draws on.