liveBook · Manning

Import-Module

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

Import-Module is a PowerShell cmdlet that loads a module into the current session from a module name or path.

Import-Module loads a PowerShell module into the current session. Give it a module name when the module is discoverable, or a complete path when it is outside PSModulePath. section 7.3

Use explicit importing when you need to control how a module becomes available:

  • Import-Module MyModule section 7.3
  • Import-Module C:\Scripts\myModules\myModule section 7.3
  • Import-Module GoogleCloud -Force reloads the module and allows its first-use installation prompt to appear. section 7.3
  • Import-Module ModuleName -Prefix MyPrefix changes Get-OriginalCmdLet to Get-MyPrefixOriginalCommand, helping avoid command conflicts. section 7.4

Importing in a remote session

Invoke-Command -ScriptBlock { Import-Module ServerManager } -Session $session loads ServerManager remotely; Import-PSSession can then bring its commands into the local session with a prefix. section 18.7

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

How deep it goes
Explains names, paths, forced reloads, prefixes, and remote use, but stops short of module implementation internals.
Examples
Demonstrates named and path-based imports, forced GoogleCloud loading, prefixed commands, and remote ServerManager loading.
What it assumes
Assumes basic PowerShell sessions and commands while explaining module names, paths, PSModulePath, and autodiscovery.
What you can do after
Apply it via PowerShell to load modules, resolve conflicts with prefixes, and prepare commands in local or remote sessions.
How it connects
Connects module loading with PSModulePath, command autodiscovery, command conflicts, Remove-Module, and Import-PSSession.

Also explained in

Compare how 2 books explain Import-Module →

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.