-
-
Save CurlyBytes/ae02fbd3c9b1b9be51b89a879d733bf9 to your computer and use it in GitHub Desktop.
[coco] A small powershell script for backing up a list of installed chocolatey packages #windows
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| param ( | |
| [string]$command = "", | |
| [string]$file = "coco.txt" | |
| ) | |
| function listInstalledPrograms() { | |
| choco list --local --id-only --limit-output | |
| } | |
| function dumpInstalledPrograms() { | |
| listInstalledPrograms | Out-File -FilePath $file | |
| Write-Host "dumped program list to $file" | |
| } | |
| switch ($command) { | |
| install { | |
| if (Test-Path $file) { | |
| choco upgrade -y (Get-Content $file) | |
| } | |
| } | |
| uninstall { | |
| if (Test-Path $file) { | |
| choco uninstall -y (Get-Content $file) | |
| } | |
| } | |
| list { | |
| listInstalledPrograms | |
| } | |
| dump { | |
| dumpInstalledPrograms | |
| } | |
| update { | |
| choco upgrade -y all | |
| dumpInstalledPrograms | |
| } | |
| default { | |
| Write-Host "usage: install|uninstall|dump [file]" | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment