API Reference
Repair-ManagedModule
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
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>]#All Parameter SetsParameters
- AcceptLicense SwitchParameter
- Accept package licenses when packages declare license acceptance is required.
- AllowClobber SwitchParameter
- Allow managed delivery to overwrite exported command conflicts.
- AllowConflict SwitchParameter
- Allow apply preparation to continue when the plan contains error findings.
- Cleanup String
- 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
- Optional repository credential.
- CredentialSecret String
- Optional repository credential secret.
- CredentialSecretFilePath String
- Optional path to a file containing the repository credential secret.
- CredentialUserName String
- Optional repository credential username.
- Family String[]
- Built-in module family policies to include in repair planning.
- Possible values:
MicrosoftGraph,Graph,Az,ExchangeOnline,Teams - Force SwitchParameter
- Force reinstall when repair selects the same installed version.
- IncludeAllUserProfiles SwitchParameter
- 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
- Include modules loaded in the current runspace as inventory and plan evidence. Cleanup protects current-runspace modules regardless of this reporting option.
- InstallMissing SwitchParameter
- Plan installs for literal names that are not present in the selected inventory.
- Inventory ModuleStateInventoryResult
- Existing inventory object. Explicit ModuleRoot and UserProfilePath destinations are merged into it and included in post-apply convergence scans.
- InventoryPath String
- Path to a previously written inventory JSON artifact.
- Latest SwitchParameter
- Plan latest-version repair/update delivery for selected installed modules.
- MaintenanceReceiptPath String[]
- Optional module-state maintenance receipt artifacts used for drift checks. Receipt-declared module roots are inventoried and retained for post-apply convergence.
- MinimumVersion String
- Minimum version used when repairing named modules.
- ModulePath String[]
- 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
- Explicit physical module root used to narrow inventory selection and managed delivery. It also resolves missing-module destination ambiguity.
- Name String[]
- Optional module names to repair. When omitted, all installed modules in scope are considered.
- Plan SwitchParameter
- Return the full repair and cleanup plan without applying any actions.
- Prerelease SwitchParameter
- Include prerelease versions during managed delivery.
- ProfileName String
- Saved repository profile used by managed delivery.
- Repository String
- Repository source or registered repository name used by managed delivery.
- RequiredResource Object
- PSResourceGet-style required resource map used as desired module state.
- RequiredResourceFile String
- Path to a PowerShell data file containing a PSResourceGet-style required resource map.
- Scope String
- Target installation scope used when selecting installed baseline modules.
- Possible values:
CurrentUser,AllUsers - ShowSummary SwitchParameter
- Write a compact Spectre.Console summary.
- SkipDependencyCheck SwitchParameter
- Skip installing dependencies declared by repaired packages.
- Transport ModuleStateDeliveryTransport
- Delivery transport used for install/update repair actions.
- Possible values:
PrivateModule,ManagedModule,Auto - UserProfilePath String[]
- 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
- Exact required version used when repairing named modules.
- VersionPolicy String
- NuGet-style version range policy used when repairing named modules.
Outputs
PSPublishModule.ModuleStateWorkflowResult: PowerShell-facing result for a complete module-state management workflow.