Skip to content

Latest commit

 

History

History
658 lines (525 loc) · 17.1 KB

File metadata and controls

658 lines (525 loc) · 17.1 KB
external help file PSPublishModule-help.xml
Module Name PSPublishModule
online version https://github.com/EvotecIT/PSPublishModule
schema 2.0.0

Repair-ManagedModule

SYNOPSIS

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

SYNTAX

__AllParameterSets

Repair-ManagedModule [[-Name] <string[]>] [-InstallMissing] [-RequiredResource <Object>] [-RequiredResourceFile <string>] [-Inventory <ModuleStateInventoryResult>] [-InventoryPath <string>] [-ModulePath <string[]>] [-UserProfilePath <string[]>] [-IncludeAllUserProfiles] [-IncludeLoaded] [-MaintenanceReceiptPath <string[]>] [-Latest] [-Version <string>] [-MinimumVersion <string>] [-VersionPolicy <string>] [-Cleanup <string>] [-Family <string[]>] [-Scope <string>] [-ProfileName <string>] [-Repository <string>] [-Transport <ModuleStateDeliveryTransport>] [-ModuleRoot <string>] [-Prerelease] [-Force] [-AllowClobber] [-AcceptLicense] [-SkipDependencyCheck] [-AllowConflict] [-Plan] [-ShowSummary] [-Credential <pscredential>] [-CredentialUserName <string>] [-CredentialSecret <string>] [-CredentialSecretFilePath <string>] [-WhatIf] [-Confirm] [<CommonParameters>]

DESCRIPTION

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

EXAMPLE 1

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

EXAMPLE 2

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

EXAMPLE 3

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

EXAMPLE 4

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

EXAMPLE 5

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

EXAMPLE 6

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

EXAMPLE 7

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

EXAMPLE 8

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

PARAMETERS

-AcceptLicense

Accept package licenses when packages declare license acceptance is required.

Type: SwitchParameter
Parameter Sets: __AllParameterSets
Aliases: None
Possible values:

Required: False
Position: named
Default value: None
Accept pipeline input: False
Accept wildcard characters: True

-AllowClobber

Allow managed delivery to overwrite exported command conflicts.

Type: SwitchParameter
Parameter Sets: __AllParameterSets
Aliases: None
Possible values:

Required: False
Position: named
Default value: None
Accept pipeline input: False
Accept wildcard characters: True

-AllowConflict

Allow apply preparation to continue when the plan contains error findings.

Type: SwitchParameter
Parameter Sets: __AllParameterSets
Aliases: None
Possible values:

Required: False
Position: named
Default value: None
Accept pipeline input: False
Accept wildcard characters: True

-Cleanup

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.

Type: String
Parameter Sets: __AllParameterSets
Aliases: None
Possible values: None, OldVersions

Required: False
Position: named
Default value: None
Accept pipeline input: False
Accept wildcard characters: True

-Credential

Optional repository credential.

Type: PSCredential
Parameter Sets: __AllParameterSets
Aliases: None
Possible values:

Required: False
Position: named
Default value: None
Accept pipeline input: False
Accept wildcard characters: True

-CredentialSecret

Optional repository credential secret.

Type: String
Parameter Sets: __AllParameterSets
Aliases: Password, Token
Possible values:

Required: False
Position: named
Default value: None
Accept pipeline input: False
Accept wildcard characters: True

-CredentialSecretFilePath

Optional path to a file containing the repository credential secret.

Type: String
Parameter Sets: __AllParameterSets
Aliases: CredentialPath, TokenPath
Possible values:

Required: False
Position: named
Default value: None
Accept pipeline input: False
Accept wildcard characters: True

-CredentialUserName

Optional repository credential username.

Type: String
Parameter Sets: __AllParameterSets
Aliases: UserName
Possible values:

Required: False
Position: named
Default value: None
Accept pipeline input: False
Accept wildcard characters: True

-Family

Built-in module family policies to include in repair planning.

Type: String[]
Parameter Sets: __AllParameterSets
Aliases: None
Possible values: MicrosoftGraph, Graph, Az, ExchangeOnline, Teams

Required: False
Position: named
Default value: None
Accept pipeline input: False
Accept wildcard characters: True

-Force

Force reinstall when repair selects the same installed version.

Type: SwitchParameter
Parameter Sets: __AllParameterSets
Aliases: None
Possible values:

Required: False
Position: named
Default value: None
Accept pipeline input: False
Accept wildcard characters: True

-IncludeAllUserProfiles

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.

Type: SwitchParameter
Parameter Sets: __AllParameterSets
Aliases: None
Possible values:

Required: False
Position: named
Default value: None
Accept pipeline input: False
Accept wildcard characters: True

-IncludeLoaded

Include modules loaded in the current runspace as inventory and plan evidence. Cleanup protects current-runspace modules regardless of this reporting option.

Type: SwitchParameter
Parameter Sets: __AllParameterSets
Aliases: None
Possible values:

Required: False
Position: named
Default value: None
Accept pipeline input: False
Accept wildcard characters: True

-InstallMissing

Plan installs for literal names that are not present in the selected inventory.

Type: SwitchParameter
Parameter Sets: __AllParameterSets
Aliases: None
Possible values:

Required: False
Position: named
Default value: None
Accept pipeline input: False
Accept wildcard characters: True

-Inventory

Existing inventory object. Explicit ModuleRoot and UserProfilePath destinations are merged into it and included in post-apply convergence scans.

Type: ModuleStateInventoryResult
Parameter Sets: __AllParameterSets
Aliases: None
Possible values:

Required: False
Position: named
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: True

-InventoryPath

Path to a previously written inventory JSON artifact.

Type: String
Parameter Sets: __AllParameterSets
Aliases: None
Possible values:

Required: False
Position: named
Default value: None
Accept pipeline input: False
Accept wildcard characters: True

-Latest

Plan latest-version repair/update delivery for selected installed modules.

Type: SwitchParameter
Parameter Sets: __AllParameterSets
Aliases: None
Possible values:

Required: False
Position: named
Default value: None
Accept pipeline input: False
Accept wildcard characters: True

-MaintenanceReceiptPath

Optional module-state maintenance receipt artifacts used for drift checks. Receipt-declared module roots are inventoried and retained for post-apply convergence.

Type: String[]
Parameter Sets: __AllParameterSets
Aliases: None
Possible values:

Required: False
Position: named
Default value: None
Accept pipeline input: False
Accept wildcard characters: True

-MinimumVersion

Minimum version used when repairing named modules.

Type: String
Parameter Sets: __AllParameterSets
Aliases: None
Possible values:

Required: False
Position: named
Default value: None
Accept pipeline input: False
Accept wildcard characters: True

-ModulePath

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.

Type: String[]
Parameter Sets: __AllParameterSets
Aliases: None
Possible values:

Required: False
Position: named
Default value: None
Accept pipeline input: False
Accept wildcard characters: True

-ModuleRoot

Explicit physical module root used to narrow inventory selection and managed delivery. It also resolves missing-module destination ambiguity.

Type: String
Parameter Sets: __AllParameterSets
Aliases: Path
Possible values:

Required: False
Position: named
Default value: None
Accept pipeline input: False
Accept wildcard characters: True

-Name

Optional module names to repair. When omitted, all installed modules in scope are considered.

Type: String[]
Parameter Sets: __AllParameterSets
Aliases: ModuleName
Possible values:

Required: False
Position: 0
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: True

-Plan

Return the full repair and cleanup plan without applying any actions.

Type: SwitchParameter
Parameter Sets: __AllParameterSets
Aliases: None
Possible values:

Required: False
Position: named
Default value: None
Accept pipeline input: False
Accept wildcard characters: True

-Prerelease

Include prerelease versions during managed delivery.

Type: SwitchParameter
Parameter Sets: __AllParameterSets
Aliases: AllowPrerelease
Possible values:

Required: False
Position: named
Default value: None
Accept pipeline input: False
Accept wildcard characters: True

-ProfileName

Saved repository profile used by managed delivery.

Type: String
Parameter Sets: __AllParameterSets
Aliases: None
Possible values:

Required: False
Position: named
Default value: None
Accept pipeline input: False
Accept wildcard characters: True

-Repository

Repository source or registered repository name used by managed delivery.

Type: String
Parameter Sets: __AllParameterSets
Aliases: Source, RepositoryUri
Possible values:

Required: False
Position: named
Default value: None
Accept pipeline input: False
Accept wildcard characters: True

-RequiredResource

PSResourceGet-style required resource map used as desired module state.

Type: Object
Parameter Sets: __AllParameterSets
Aliases: None
Possible values:

Required: False
Position: named
Default value: None
Accept pipeline input: False
Accept wildcard characters: True

-RequiredResourceFile

Path to a PowerShell data file containing a PSResourceGet-style required resource map.

Type: String
Parameter Sets: __AllParameterSets
Aliases: None
Possible values:

Required: False
Position: named
Default value: None
Accept pipeline input: False
Accept wildcard characters: True

-Scope

Target installation scope used when selecting installed baseline modules.

Type: String
Parameter Sets: __AllParameterSets
Aliases: None
Possible values: CurrentUser, AllUsers

Required: False
Position: named
Default value: None
Accept pipeline input: False
Accept wildcard characters: True

-ShowSummary

Write a compact Spectre.Console summary.

Type: SwitchParameter
Parameter Sets: __AllParameterSets
Aliases: None
Possible values:

Required: False
Position: named
Default value: None
Accept pipeline input: False
Accept wildcard characters: True

-SkipDependencyCheck

Skip installing dependencies declared by repaired packages.

Type: SwitchParameter
Parameter Sets: __AllParameterSets
Aliases: SkipDependenciesCheck
Possible values:

Required: False
Position: named
Default value: None
Accept pipeline input: False
Accept wildcard characters: True

-Transport

Delivery transport used for install/update repair actions.

Type: ModuleStateDeliveryTransport
Parameter Sets: __AllParameterSets
Aliases: None
Possible values: PrivateModule, ManagedModule, Auto

Required: False
Position: named
Default value: None
Accept pipeline input: False
Accept wildcard characters: True

-UserProfilePath

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.

Type: String[]
Parameter Sets: __AllParameterSets
Aliases: None
Possible values:

Required: False
Position: named
Default value: None
Accept pipeline input: False
Accept wildcard characters: True

-Version

Exact required version used when repairing named modules.

Type: String
Parameter Sets: __AllParameterSets
Aliases: RequiredVersion
Possible values:

Required: False
Position: named
Default value: None
Accept pipeline input: False
Accept wildcard characters: True

-VersionPolicy

NuGet-style version range policy used when repairing named modules.

Type: String
Parameter Sets: __AllParameterSets
Aliases: None
Possible values:

Required: False
Position: named
Default value: None
Accept pipeline input: False
Accept wildcard characters: True

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTS

  • System.String[] PSPublishModule.ModuleStateInventoryResult

OUTPUTS

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

RELATED LINKS

  • None