# Operational best practices

LLMS index: [llms.txt](/llms.txt)

---

This page describes recommended operating patterns for PackageUpdateInfo in
interactive shells, profiles, and automation.

## Start with default behavior

Reset settings before introducing custom tuning, especially on shared systems:

```powershell
Set-PackageUpdateSetting -Reset
```

Inspect current configuration and rules:

```powershell
Get-PackageUpdateSetting
Get-PackageUpdateRule -IncludeDefaultRule
```

## Use update intervals to reduce noise

`Get-PackageUpdateInfo` respects `UpdateCheckInterval`. If the last effective
check is still within the configured interval, the cmdlet returns early.

Set an interval that matches your environment:

```powershell
Set-PackageUpdateSetting -UpdateCheckInterval (New-TimeSpan -Hours 6)
```

Use `-Force` only for ad-hoc verification runs:

```powershell
Get-PackageUpdateInfo -Force
```

## Prefer non-blocking shell startup

A practical profile pattern is:

```powershell
Start-Job -ScriptBlock {
    Get-PackageUpdateInfo -ShowOnlyNeededUpdate | Export-PackageUpdateInfo
} | Out-Null

Import-PackageUpdateInfo
```

Why this works well:

- Startup remains fast because import reads cached data.
- The expensive online check runs in the background.
- You still get useful update visibility in each session.

## Scope checks explicitly when needed

Use scope parameters when permissions differ between user and system modules:

```powershell
Get-PackageUpdateInfo -CurrentUser
Get-PackageUpdateInfo -AllUsers
```

Use `-Repository` in environments with multiple configured repositories:

```powershell
Get-PackageUpdateInfo -Repository PSGallery
```

## Design rules carefully

Use broad excludes only when intentional. Excluding large patterns can hide
important updates.

Create focused custom rules for high-churn modules:

```powershell
Add-PackageUpdateRule -IncludeModuleForChecking "Az.*" -ReportChangeOnMajor $true -ReportChangeOnMinor $true -ReportChangeOnBuild $false -ReportChangeOnRevision $false
```

Review rule precedence by listing all rules:

```powershell
Get-PackageUpdateRule -IncludeDefaultRule | Sort-Object Id
```

## Use export/import intentionally

Default export and import paths are platform-specific and include PowerShell
edition and major version in the filename. This helps avoid mixing data from
different runtimes.

Common export options:

```powershell
Get-PackageUpdateInfo | Export-PackageUpdateInfo -OutputFormat XML
Get-PackageUpdateInfo | Export-PackageUpdateInfo -OutputFormat JSON
Get-PackageUpdateInfo | Export-PackageUpdateInfo -OutputFormat CSV
```

Recommended guidance:

- Use XML when you want to preserve typed objects for re-import.
- Use JSON or CSV for external reporting and integration.
- Use `-IncludeTimeStamp` for historical tracking.

## Keep notifications useful

Use toast notifications only where they add value:

- On Windows hosts with BurntToast installed.
- On sessions where interactive alerts are expected.

For servers, CI, and non-interactive shells, prefer exported reports over toast
notifications.
