# A New PC from One File: \`winget export\` and \`import\`

winget export writes the list of apps on a PC to a JSON file, which PowerShell can read and change with ConvertFrom-Json and ConvertTo-Json -Depth, and winget import installs every app on the list on a new PC in one command.

Journeyman · PowerShell · Operating System · Updated November 10, 2026

## After this lesson you can

- Save a PC's app list with winget export, and read or change the export file with ConvertFrom-Json and ConvertTo-Json -Depth
- Install every app in an export file on a new PC with winget import and its agreement and --ignore-unavailable switches
- Choose between Get-CimInstance, Get-WinEvent, the registry, the local-account commands and winget for a question about a PC

## Key takeaways

- `winget export --output apps.json` writes the apps winget knows on this PC into one JSON file; apps it can't find in a source are left out, with a warning.
- The file is JSON: `ConvertFrom-Json` reads it, and `.Sources.Packages.PackageIdentifier` lists the apps.
- To change the list, change the objects, then save with `ConvertTo-Json -Depth 5`; without `-Depth`, the list of apps is cut off.
- `winget import --import-file apps.json` installs every app on the list. `--accept-package-agreements` and `--accept-source-agreements` let it run without stopping to ask.
- The file brings back apps, not your files or settings.

A new laptop is exciting for about an hour, until you remember everything you need on it: the browser, the editor, the media player, the zip tool, PowerShell 7. You install them one by one from memory and find the one you forgot a week later, when you need it. An IT team setting up ten laptops for new hires has the same problem ten times over. **winget**, Windows' package manager from *Installing Apps and Modules: winget and the PowerShell Gallery*, can write the whole list to one file on the old PC and install everything on it on the new one.

## The list, in one file: \`winget export\`

`winget export` writes the apps on this PC that winget knows into a file. `--output` (read "output") names the file:

```powershell
winget export --output "$HOME\terminal-practice\new-pc\apps.json"
```

It prints a line for every installed app that isn't in any of winget's sources, such as a program that came on a disc or a driver from your PC's maker, and leaves those out of the file. The file holds the rest: on a PC that's been in use for a while, often 30 to 60 apps. Your list is your own business, so this lesson works on a small made-up list instead. These lines make it; they print nothing, and running them again makes the same file:

```powershell
New-Item -ItemType Directory -Force -Path "$HOME\terminal-practice\new-pc" | Out-Null
Set-Location "$HOME\terminal-practice\new-pc"
Set-Content -Path apps.json -Value @'
{
  "$schema": "https://aka.ms/winget-packages.schema.2.0.json",
  "CreationDate": "2026-11-09T09:30:00.000-00:00",
  "Sources": [
    {
      "Packages": [
        { "PackageIdentifier": "Microsoft.PowerShell" },
        { "PackageIdentifier": "Microsoft.VisualStudioCode" },
        { "PackageIdentifier": "Mozilla.Firefox" },
        { "PackageIdentifier": "VideoLAN.VLC" },
        { "PackageIdentifier": "7zip.7zip" }
      ],
      "SourceDetails": {
        "Argument": "https://cdn.winget.microsoft.com/cache",
        "Identifier": "Microsoft.Winget.Source_8wekyb3d8bbwe",
        "Name": "winget",
        "Type": "Microsoft.PreIndexed.Package"
      }
    }
  ],
  "WinGetVersion": "1.29.380"
}
'@
```

That's the shape of a real export, written more compactly than winget writes it. `Sources` is a list of the places the apps come from, here only `winget`'s own catalog; apps from the Microsoft Store get a second entry, `msstore`. Inside, `Packages` lists each app by its **package identifier**, the exact Id you met in `winget search`. Add `--include-versions` to `winget export`, and each app gets its version too.

## Read it and change it: it's JSON

The file is JSON, so *JSON: `ConvertFrom-Json` and `ConvertTo-Json`* already taught you how to read it. A dot after a list reaches into every item in it, so one line lists every app:

```powershell
$apps = Get-Content .\apps.json -Raw | ConvertFrom-Json
$apps.Sources.Packages.PackageIdentifier
```

```text
Microsoft.PowerShell
Microsoft.VisualStudioCode
Mozilla.Firefox
VideoLAN.VLC
7zip.7zip
```

The new laptop is for work, and it doesn't need the media player. Change the objects, then save them. `Sources[0]` is the first source; `Where-Object` keeps every app but VLC:

```powershell
$apps.Sources[0].Packages = @($apps.Sources[0].Packages | Where-Object PackageIdentifier -ne 'VideoLAN.VLC')
$apps | ConvertTo-Json -Depth 5 | Set-Content .\apps.json
(Get-Content .\apps.json -Raw | ConvertFrom-Json).Sources.Packages.PackageIdentifier
```

```text
Microsoft.PowerShell
Microsoft.VisualStudioCode
Mozilla.Firefox
7zip.7zip
```

`-Depth 5` matters. Each app sits three levels deep (the file, `Sources`, `Packages`), and `ConvertTo-Json` stops at two unless told otherwise: PowerShell warns *Resulting JSON is truncated as serialization has exceeded the set depth of 2*, and the app list in the file becomes blank text. Adding an app is `+=` with a new object, such as `[PSCustomObject]@{ PackageIdentifier = 'Notepad++.Notepad++' }`.

## Everything back in one command: \`winget import\`

On the new PC, copy `apps.json` over (a USB stick or a cloud folder), install PowerShell 7 if you want it there first, and ask winget what `import` takes:

```powershell
winget import --help
```

```text
Windows Package Manager v1.29.380
© 2026 Microsoft. All rights reserved.

Installs all the packages listed in a file.

usage: winget import [-i] <import-file> [<options>]

The following arguments are available:
  -i,--import-file             File describing the packages to install

The following options are available:
  --ignore-unavailable         Ignore unavailable packages
  --ignore-versions            Ignore package versions in import file
  --no-upgrade                 Skips upgrade if an installed version already exists
  --accept-package-agreements  Accept all license agreements for packages
  --accept-source-agreements   Accept all source agreements during source operations
  -?,--help                    Shows help about the selected command
  --wait                       Prompts the user to press any key before exiting
  --logs,--open-logs           Open the default logs location
  --verbose,--verbose-logs     Enables verbose logging for winget
  --nowarn,--ignore-warnings   Suppresses warning outputs
  --disable-interactivity      Disable interactive prompts
  --proxy                      Set a proxy to use for this execution
  --no-proxy                   Disable the use of proxy for this execution

More help can be found at: https://aka.ms/winget-command-import
```

Then the import itself. It installs every app on the list, one after another, so this lesson leaves running it to you, on the PC that needs the apps:

```powershell
winget import --import-file .\apps.json --accept-package-agreements --accept-source-agreements --ignore-unavailable
```

The two `--accept-` switches say yes to each app's license and to the catalog's terms up front, so the import doesn't stop to ask; read them once, the first time. `--ignore-unavailable` carries on past an app the catalog no longer has, instead of stopping. An app that's already installed is updated if a newer version is waiting, unless you add `--no-upgrade`. Some installers still ask Windows for permission; click **Yes** only for the app you meant.

The file brings back apps, not your files or your settings: those come from a backup or a cloud folder. winget is Windows only, and it works the same from Windows PowerShell 5.1.

## Five places to look

This chapter has given you five places to look when someone asks about a Windows PC:

- What's in it and how full it is: `Get-CimInstance`, in *Your Computer's Facts: `Get-CimInstance`*.
- What happened to it, and when: `Get-WinEvent`, in *Event Logs: Why Did It Restart?*
- How it's set up: the registry, in *The Registry as a Drive*.
- Who can use it, and who can change it: `Get-LocalUser` and `Get-LocalGroupMember`, in *Users and Groups on This PC*.
- Which apps it has: `winget`, here.

## Check yourself

2 questions to try on the lesson page.

## So what

One file holds the list of apps a PC needs: export it once, trim it with the JSON skills you already have, and a new PC is set up with one import instead of an afternoon of downloads.

## Key terms

- [winget](https://www.ask-codey.com/glossary/winget)
- [winget export](https://www.ask-codey.com/glossary/winget-export)
- [winget import](https://www.ask-codey.com/glossary/winget-import)
- [JSON](https://www.ask-codey.com/glossary/json)
- [ConvertTo-Json](https://www.ask-codey.com/glossary/convertto-json)

## Cheat sheets

- [A New PC from One File: \`winget export\` and \`import\`](https://www.ask-codey.com/cheat-sheets/powershell-winget-export-cheat-sheet)

## Related

- [Installing Apps and Modules: winget and the PowerShell Gallery](https://www.ask-codey.com/lessons/powershell-installing-tools)
- [JSON: ConvertFrom-Json and ConvertTo-Json](https://www.ask-codey.com/lessons/powershell-json)
- [Your Computer's Facts: \`Get-CimInstance\`](https://www.ask-codey.com/lessons/powershell-cim)

Source: https://www.ask-codey.com/lessons/powershell-winget-export
