Restore-MtPack
Synopsis
Section titled “Synopsis”Installs exactly the packs and modules that maester-packs.lock.json records, on a new computer or in a pipeline.
Syntax
Section titled “Syntax”Restore-MtPack [[-Id] <String[]>] [-PackLock <String>] [-Token <SecureString>] [-ProgressAction <ActionPreference>] [-WhatIf] [-Confirm] [<CommonParameters>]Description
Section titled “Description”For each pack in the lock file whose files are not in the local pack store, the recorded commit is fetched and its digest must equal the digest in the lock file; a pack whose files differ is not restored. Each module in the lock file is saved at its exact version and must match its recorded digest. Nothing is asked: the lock file is the approval, made when the pack was installed. A module that was externally managed when it was approved is not saved; it must be installed on this computer at the same version and with the same files.
Run it before Invoke-Maester in a pipeline that commits maester-config.json and maester-packs.lock.json.
Examples
Section titled “Examples”Example 1
Section titled “Example 1”Restore-MtPackRestores every pack of the lock file found from the current folder.
Example 2
Section titled “Example 2”Restore-MtPack -PackLock ./maester/maester-packs.lock.json; Invoke-Maester -Path ./maesterRestores, then runs, in a pipeline.
Example 3
Section titled “Example 3”Restore-MtPack -Token (Get-Secret -Name PackReadToken)Restores packs from private repositories with a token read from a secret vault.
Parameters
Section titled “Parameters”Restore only these packs. By default every pack in the lock file.
Type: String[]Parameter Sets: (All)Aliases:
Required: FalsePosition: 1Default value: NoneAccept pipeline input: FalseAccept wildcard characters: False-PackLock
Section titled “-PackLock”The lock file to restore from. By default the one beside the Maester config found from the current folder, else the user’s.
Type: StringParameter Sets: (All)Aliases:
Required: FalsePosition: NamedDefault value: NoneAccept pipeline input: FalseAccept wildcard characters: False-Token
Section titled “-Token”A GitHub token that can read the pack’s repository, as a SecureString, for a private or internal
repository.
It is used for this command only, is sent to api.github.com only, and is not stored.
When it
is given, no other sign-in is tried.
Without it, Maester uses the first of these that can read the
repository: the sign-in of Connect-MtGitHub in this session, the GitHub CLI (gh auth token, when gh is
installed and signed in), then the GH_TOKEN and GITHUB_TOKEN environment variables.
An environment
variable can be read by every process and module in the session, including installed packs, so prefer
the other ways outside a pipeline.
A fine-grained token needs only read-only Contents access to the
one repository.
Type: SecureStringParameter Sets: (All)Aliases:
Required: FalsePosition: NamedDefault value: NoneAccept pipeline input: FalseAccept wildcard characters: False-WhatIf
Section titled “-WhatIf”Shows what would happen if the cmdlet runs. The cmdlet is not run.
Type: SwitchParameterParameter Sets: (All)Aliases: wi
Required: FalsePosition: NamedDefault value: NoneAccept pipeline input: FalseAccept wildcard characters: False-Confirm
Section titled “-Confirm”Prompts you for confirmation before running the cmdlet.
Type: SwitchParameterParameter Sets: (All)Aliases: cf
Required: FalsePosition: NamedDefault value: NoneAccept pipeline input: FalseAccept wildcard characters: False-ProgressAction
Section titled “-ProgressAction”Determines how PowerShell responds to progress updates generated by a script, cmdlet, or provider, such as the progress bars generated by Write-Progress.
Type: ActionPreferenceParameter Sets: (All)Aliases: proga
Required: FalsePosition: NamedDefault value: NoneAccept pipeline input: FalseAccept wildcard characters: FalseCommonParameters
Section titled “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.