Project

PSPublishModule

Build, test, version, sign, and publish PowerShell modules with reusable PowerForge pipelines.

Stars 48
Forks 16
PowerShell Gallery downloads 17,213
Release v3.0.169
Language: C# Updated: 2026-10-13

API Reference

Command

Repair-ManagedModule

Namespace PSPublishModule
Inputs
PSPublishModule.ModuleStateInventoryResult System.String[]
Outputs
PSPublishModule.ModuleStateWorkflowResult

Repairs and verifies installed PowerShell modules through the managed module-state engine.

Remarks

This command is the managed operator surface for module estate maintenance. It inventories installed modules, plans stale-version, receipt-drift, source, scope, family, and cleanup actions, and can apply the plan through the managed delivery engine. PSResourceGet has no equivalent estate-repair command. Use the lifecycle cmdlets for one requested operation and this command when the desired outcome spans installed-state discovery, drift analysis, repair, and cleanup. Repair keeps module copies in separate physical roots, PowerShell editions, scopes, and local user profiles independent. Missing modules require an explicit ModuleRoot or exactly one eligible scanned root; ambiguous destinations are reported and blocked. A single explicit UserProfilePath supplies the current PowerShell edition's standard CurrentUser root even when that root does not exist yet; it never overrides an AllUsers request. Explicit ModuleRoot and profile destinations are merged into supplied Inventory or InventoryPath artifacts and remain part of convergence scans. Module roots declared by maintenance receipts are merged the same way, including roots that do not exist until repair delivery creates them. A successfully enumerated explicit root replaces stale artifact rows and diagnostics for that root, even when the live root is empty. Live apply performs delivery, inventories the same estate again, replans exact-path old-version cleanup from current state. Cleanup requires that refreshed plan to be error-free, preflights the complete exact-path removal set, validates loaded-module and dependency safety across relevant global/profile roots, and removes selected dependents before their selected dependencies. Current-runspace loaded modules are protected even when IncludeLoaded is not used for inventory output. A declined delivery or cleanup action is reported as skipped and cannot be reported as successful convergence. Repair performs a final live inventory and returns post-apply plan and convergence evidence after execution or a no-action apply. Operational failures remain visible in the typed result and are also written as nonterminating errors. This is local-machine estate management suitable for workstations and servers, including service-account and multi-profile roots. It does not connect to or orchestrate remote computers; invoke it in each target session or through the operator's existing remoting/configuration system.

Examples

Authored help example

Preview latest-version repair for installed modules


Repair-ManagedModule -Latest -Repository PSGallery -Plan -ShowSummary
        

Preview version-coherence repair for Graph modules


Repair-ManagedModule -Family Graph -Repository PSGallery -Plan -ShowSummary
        

Preview baseline enforcement from a list of module names


Repair-ManagedModule -Name Company.Tools,Company.Web -InstallMissing -Latest -Repository PSGallery -Plan -ShowSummary
        

Preview baseline enforcement from a PSResourceGet-style resource file


Repair-ManagedModule -RequiredResourceFile .\required-resources.psd1 -Latest -Repository PSGallery -Plan -ShowSummary
        

Apply receipt-drift repair through a managed repository profile


Repair-ManagedModule -MaintenanceReceiptPath .\module-maintenance.json -ProfileName CompanyModules -AcceptLicense
        

Preview repair across Windows PowerShell and PowerShell 7 roots


Repair-ManagedModule -ModulePath $ps5Root,$ps7Root -Latest -Cleanup OldVersions -Repository PSGallery -Plan -ShowSummary
        

Preview modules installed for multiple local user profiles


Repair-ManagedModule -UserProfilePath C:\Users\Alice,C:\Users\Service.PowerShell -Name Company.* -Latest -Repository CompanyModules -Plan -ShowSummary
        

Apply safe old-version cleanup and verify convergence


Repair-ManagedModule -IncludeAllUserProfiles -Latest -Cleanup OldVersions -Repository CompanyModules -Confirm:$false -ShowSummary
        

Common Parameters

This command supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.

For more information, see about_CommonParameters.

Syntax

Repair-ManagedModule [-AcceptLicense] [-AllowClobber] [-AllowConflict] [-Cleanup <OldVersions>] [-Credential <PSCredential>] [-CredentialSecret <String>] [-CredentialSecretFilePath <String>] [-CredentialUserName <String>] [-Family <MicrosoftGraph|Graph|Az|ExchangeOnline|Teams>] [-Force] [-IncludeAllUserProfiles] [-IncludeLoaded] [-InstallMissing] [-Inventory <ModuleStateInventoryResult>] [-InventoryPath <String>] [-Latest] [-MaintenanceReceiptPath <String[]>] [-MinimumVersion <String>] [-ModulePath <String[]>] [-ModuleRoot <String>] [-Name <String[]>] [-Plan] [-Prerelease] [-ProfileName <String>] [-Repository <String>] [-RequiredResource <Object>] [-RequiredResourceFile <String>] [-Scope <CurrentUser|AllUsers>] [-ShowSummary] [-SkipDependencyCheck] [-Transport <PrivateModule|ManagedModule|Auto>] [-UserProfilePath <String[]>] [-Version <String>] [-VersionPolicy <String>] [<CommonParameters>]
#
Parameter set: All Parameter Sets

Parameters

AcceptLicense SwitchParameter optionalposition: namedpipeline: False
Accept package licenses when packages declare license acceptance is required.
AllowClobber SwitchParameter optionalposition: namedpipeline: False
Allow managed delivery to overwrite exported command conflicts.
AllowConflict SwitchParameter optionalposition: namedpipeline: False
Allow apply preparation to continue when the plan contains error findings.
Cleanup String optionalposition: namedpipeline: Falsevalues: 1
Optional old-version cleanup. Live apply replans after delivery, requires an error-free refreshed estate, batch-preflights exact paths, and removes selected dependents before dependencies.
Possible values: OldVersions
Credential PSCredential optionalposition: namedpipeline: False
Optional repository credential.
CredentialSecret String optionalposition: namedpipeline: Falsealiases: Password, Token
Optional repository credential secret.
CredentialSecretFilePath String optionalposition: namedpipeline: Falsealiases: CredentialPath, TokenPath
Optional path to a file containing the repository credential secret.
CredentialUserName String optionalposition: namedpipeline: Falsealiases: UserName
Optional repository credential username.
Family String[] optionalposition: namedpipeline: Falsevalues: 5
Built-in module family policies to include in repair planning.
Possible values: MicrosoftGraph, Graph, Az, ExchangeOnline, Teams
Force SwitchParameter optionalposition: namedpipeline: False
Force reinstall when repair selects the same installed version.
IncludeAllUserProfiles SwitchParameter optionalposition: namedpipeline: False
Discover existing standard PowerShell module roots below the local profile container. Unix root sessions scan /home and retain /root; inaccessible optional profiles or roots are reported as warnings. Use UserProfilePath or ModulePath for redirected and custom layouts.
IncludeLoaded SwitchParameter optionalposition: namedpipeline: False
Include modules loaded in the current runspace as inventory and plan evidence. Cleanup protects current-runspace modules regardless of this reporting option.
InstallMissing SwitchParameter optionalposition: namedpipeline: False
Plan installs for literal names that are not present in the selected inventory.
Inventory ModuleStateInventoryResult optionalposition: namedpipeline: True (ByValue)
Existing inventory object. Explicit ModuleRoot and UserProfilePath destinations are merged into it and included in post-apply convergence scans.
InventoryPath String optionalposition: namedpipeline: False
Path to a previously written inventory JSON artifact.
Latest SwitchParameter optionalposition: namedpipeline: False
Plan latest-version repair/update delivery for selected installed modules.
MaintenanceReceiptPath String[] optionalposition: namedpipeline: False
Optional module-state maintenance receipt artifacts used for drift checks. Receipt-declared module roots are inventoried and retained for post-apply convergence.
MinimumVersion String optionalposition: namedpipeline: False
Minimum version used when repairing named modules.
ModulePath String[] optionalposition: namedpipeline: False
Explicit required module roots to inventory. Missing or inaccessible roots block apply. When omitted, optional roots inherited together from the current process's PSModulePath are treated as one dependency-visibility context.
ModuleRoot String optionalposition: namedpipeline: Falsealiases: Path
Explicit physical module root used to narrow inventory selection and managed delivery. It also resolves missing-module destination ambiguity.
Name String[] optionalposition: 0pipeline: True (ByPropertyName)aliases: ModuleName
Optional module names to repair. When omitted, all installed modules in scope are considered.
Plan SwitchParameter optionalposition: namedpipeline: False
Return the full repair and cleanup plan without applying any actions.
Prerelease SwitchParameter optionalposition: namedpipeline: Falsealiases: AllowPrerelease
Include prerelease versions during managed delivery.
ProfileName String optionalposition: namedpipeline: False
Saved repository profile used by managed delivery.
Repository String optionalposition: namedpipeline: Falsealiases: RepositoryUri, Source
Repository source or registered repository name used by managed delivery.
RequiredResource Object optionalposition: namedpipeline: False
PSResourceGet-style required resource map used as desired module state.
RequiredResourceFile String optionalposition: namedpipeline: False
Path to a PowerShell data file containing a PSResourceGet-style required resource map.
Scope String optionalposition: namedpipeline: Falsevalues: 2
Target installation scope used when selecting installed baseline modules.
Possible values: CurrentUser, AllUsers
ShowSummary SwitchParameter optionalposition: namedpipeline: False
Write a compact Spectre.Console summary.
SkipDependencyCheck SwitchParameter optionalposition: namedpipeline: Falsealiases: SkipDependenciesCheck
Skip installing dependencies declared by repaired packages.
Transport ModuleStateDeliveryTransport optionalposition: namedpipeline: Falsevalues: 3
Delivery transport used for install/update repair actions.
Possible values: PrivateModule, ManagedModule, Auto
UserProfilePath String[] optionalposition: namedpipeline: False
Explicit user profile home directories whose platform-standard module roots are inventoried. Existing roots are required and block repair when inaccessible; a missing current-edition root remains a creatable destination. One explicit profile provides that CurrentUser destination for missing modules, but never overrides AllUsers scope.
Version String optionalposition: namedpipeline: Falsealiases: RequiredVersion
Exact required version used when repairing named modules.
VersionPolicy String optionalposition: namedpipeline: False
NuGet-style version range policy used when repairing named modules.

Outputs

PSPublishModule.ModuleStateWorkflowResult: PowerShell-facing result for a complete module-state management workflow.