# Restore-MtPack

Installs exactly the packs and modules that maester-packs.lock.json records, on a new computer or in a pipeline.

Source: https://maester.dev/docs/commands/Restore-MtPack

## SYNOPSIS

Installs exactly the packs and modules that maester-packs.lock.json records, on a new computer or in a pipeline.

## SYNTAX

```powershell
Restore-MtPack [[-Id] <String[]>] [-PackLock <String>] [-Token <SecureString>]
 [-ProgressAction <ActionPreference>] [-WhatIf] [-Confirm] [<CommonParameters>]
```

## 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

### EXAMPLE 1

```powershell
Restore-MtPack
```

Restores every pack of the lock file found from the current folder.

### EXAMPLE 2

```powershell
Restore-MtPack -PackLock ./maester/maester-packs.lock.json; Invoke-Maester -Path ./maester
```

Restores, then runs, in a pipeline.

### EXAMPLE 3

```powershell
Restore-MtPack -Token (Get-Secret -Name PackReadToken)
```

Restores packs from private repositories with a token read from a secret vault.

## PARAMETERS

### -Id

Restore only these packs.
By default every pack in the lock file.

```yaml
Type: String[]
Parameter Sets: (All)
Aliases:

Required: False
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -PackLock

The lock file to restore from.
By default the one beside the Maester config found from the current
folder, else the user's.

```yaml
Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -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.

```yaml
Type: SecureString
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -WhatIf

Shows what would happen if the cmdlet runs.
The cmdlet is not run.

```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases: wi

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -Confirm

Prompts you for confirmation before running the cmdlet.

```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases: cf

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -ProgressAction

Determines how PowerShell responds to progress updates generated by a script, cmdlet, or provider, such as the progress bars generated by Write-Progress.

```yaml
Type: ActionPreference
Parameter Sets: (All)
Aliases: proga

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### 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](http://go.microsoft.com/fwlink/?LinkID=113216).

## INPUTS

## OUTPUTS

### System.Management.Automation.PSObject

## NOTES

## RELATED LINKS

[https://maester.dev/docs/commands/Restore-MtPack](https://maester.dev/docs/commands/Restore-MtPack)
