Use this when packaging or installing PowerShell modules.
Modules · PowerShell Automation
PowerShell modules package functions, cmdlets and resources (.psm1 with a .psd1 manifest), installed from the PowerShell Gallery with Install-Module and loaded with Import-Module.
1. Modules package functions (psm1, psd1 manifest).
2. Pin versions.
3. Trusted repositories (PSGallery, internal).
4. Sign modules for production.
5. Export only public functions.
module → manifest → imported commands
Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 Verification path Verify boundary
Use Get-Module -ListAvailable to inventory installed versions, Import-Module -PassThru to show the version actually loaded, and Get-Command -Module <name> or Get-Command <name> -All to verify exported command resolution. After module updates, create a fresh runspace/process so already-loaded assemblies or classes do not mask version behavior.
Step 2 Common mistakes Narrow the fault
- Module versions not pinned.
Step 3 Where it fails Narrow the fault
Module auto-loading is convenience, not dependency control. Updating module files under a running session may not replace loaded types/assemblies, and removing a module may not fully undo side effects. Separate installation inventory, module resolution, imported runtime state, exported command identity and target operation results.
Evidence · 1 on this Topic
Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.
- Modules package functions (.psm1) with a manifest (.psd1).
- Install-Module installs from the PowerShell Gallery.
- Pin versions with -RequiredVersion.
Get-Module -ListAvailable <name>— installedInstall-Module <name> -Scope CurrentUser— install (PSGallery)Import-Module <name> -RequiredVersion <v>— pin version
ReferenceWhy it matters1 section · depth on demand
In depth
A PowerShell module packages functions, variables and resources into a unit that can be versioned, shared and imported. Modules turn collections of scripts into maintainable tooling, and are the format for publishing to the PowerShell Gallery or an internal repository.
NetOps/
NetOps.psd1 # manifest: version, exported functions, dependencies
NetOps.psm1 # loads Public/ and Private/
Public/Get-SwitchInventory.ps1
Private/Invoke-NetboxApi.ps1
Tests/NetOps.Tests.ps1
New-ModuleManifest .\NetOps\NetOps.psd1 -RootModule NetOps.psm1 -ModuleVersion 1.2.0 -FunctionsToExport 'Get-SwitchInventory'
Import-Module .\NetOps -Force
Publish-Module -Path .\NetOps -Repository Internal
Export only public functions, declare required modules in the manifest, and test with Pester before publishing.
ReferenceImportant terms & boundaries1 section · depth on demand
PowerShell mechanics
PowerShell modules package commands, types, format data and other resources behind a module identity and version. Discovery searches locations such as $env:PSModulePath; autoload can import a module when a command is first used, and multiple installed versions can create command-resolution ambiguity. Manifest metadata, nested modules and exported members shape the public surface seen by automation.
ReferenceConfiguration & state1 section · depth on demand
Authoring and lifecycle
Treat module dependencies as deployable prerequisites: pin or constrain versions where compatibility matters, use manifests for reusable code, and avoid relying on whichever version happens to be first on PSModulePath. Import into controlled sessions and record version/source. For internal modules, version and test the public command contract before rollout.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Microsoft Learn documentation reviewed for bounded PowerShell reference claims. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://learn.microsoft.com/en-us/powershell/scripting/developer/module/importing-a-powershell-module?view=powershell-7.5 · confidence 94%Quick lookup tables
Modules · PowerShell operational reference
Topic-specific PowerShell runtime identity, persistence, verification, output and failure-boundary lookup.
| Boundary | Modules reference |
|---|---|
| Runtime identity | PowerShell edition/version + command/module source |
| Persistent intent | Script/module/config prerequisites under source control |
| Verification | Read-only discovery → execution evidence → independent target read-back |
| Output contract | Structured objects/streams before formatting |
| Failure boundary | Separate engine/binding from transport/API/native and target-state failures |
Deep reference
Healthy vs suspicious evidence
Output interpretation
Installed, discoverable and imported are different states. The filesystem can contain multiple versions while one version is loaded, and command shadowing can select a function/alias from elsewhere. A successful module import only shows initialization, but it does not show downstream services or credentials are available.