Skip to content

Scripts Windows PackageManagers

Quadstronaut edited this page Jun 7, 2026 · 1 revision

Scripts: Package Managers

Scripts in Scripts/Windows/PackageManagers/.


Import-ChocolateyPackages.ps1

What it does: "Late adoption" script — brings software you already installed manually under Chocolatey management without reinstalling.

How it works:

  1. Requires administrator privileges (exits if not admin).
  2. Scans C:\Program Files\ and C:\Program Files (x86)\ for .exe files.
  3. For each executable found, queries the Chocolatey repository via Find-Package -Provider chocolatey for a matching package.
  4. If any matches are found:
    • Installs Chocolatey if missing.
    • Pins each matched package (choco pin add -n=<name>).
    • Upgrades all matched packages (choco upgrade <names> -y).

Parameters: None.

Requirements: Administrator privileges. Chocolatey is installed automatically if missing. Internet access required for the package search.

Usage:

.\Scripts\Windows\PackageManagers\Import-ChocolateyPackages.ps1

Notes:

  • Find-Package -Provider chocolatey is slower than choco search — it queries the API for each exe file found. On a machine with many installed programs this can take several minutes.
  • Matching is by executable filename, not by product name — a match means a Chocolatey package exists with that exe name, not necessarily the same application. Review the matched list before confirming.
  • If Chocolatey is not already installed, the script installs it inline before pinning — this temporarily sets the process execution policy to Bypass.

Update-PythonInstallation.ps1

What it does: Detects installed Python versions, upgrades to the latest, removes older versions, upgrades pip, and optionally removes virtual environments.

How it works:

  1. Requires administrator privileges.
  2. Installs Chocolatey if missing.
  3. Detects Python versions via choco list python --local-only (preferred) or via registry (HKLM:\Software\Python\PythonCore).
  4. Sorts by version descending. Identifies the latest version.
  5. For each older version: runs choco upgrade <package> -y then choco uninstall <package> -y. (If not using Chocolatey, runs the uninstaller directly from the install path.)
  6. Upgrades pip: python -m pip install --upgrade pip.
  7. Looks for virtual environments in $env:USERPROFILE\Envs (virtualenvwrapper convention). If found, prompts to delete them.

Parameters: None (interactive prompts for venv deletion).

Requirements: Administrator privileges. Chocolatey recommended; falls back to registry detection.

Usage:

.\Scripts\Windows\PackageManagers\Update-PythonInstallation.ps1

Known limitations:

  • The Chocolatey path runs both choco upgrade and choco uninstall on each old version sequentially. Since upgrade changes the installed version, the subsequent uninstall targets the package by name — this may or may not correctly remove the old version depending on how Chocolatey tracks versioned Python packages.
  • The venv search path ($env:USERPROFILE\Envs) is specific to virtualenvwrapper-win. Standard python -m venv environments are not scanned.
  • If Python is not on the PATH after upgrade, the pip install --upgrade pip step will fail silently or target the wrong interpreter.

Invoke-ScoopBrowser.ps1

What it does: An interactive terminal browser for Scoop packages. Shows package info for each available package and lets you install selected ones in the background while you keep browsing.

How it works:

  1. Checks that Scoop is installed; exits with an error message if not.
  2. Runs scoop search to get the package list.
  3. For each package, clears the screen, shows scoop info <name>, and prompts for Y/N.
  4. If Y, starts a background job (Start-Job) to run scoop install <name>.
  5. At the end, lists all running installation jobs and how to retrieve their output.

Parameters: None.

Requirements: Scoop installed. No admin rights required.

Usage:

.\Scripts\Windows\PackageManagers\Invoke-ScoopBrowser.ps1

Notes:

  • scoop search without arguments returns all packages in all configured buckets — this can be hundreds or thousands of entries. The browser is designed for exploration, not a quick targeted search.
  • Background jobs run as separate PowerShell processes. To check progress or see install output:
    Get-Job                    # list all jobs and their state
    Receive-Job -Id <JobId>    # get output from a specific job
    Wait-Job -Id <JobId>       # block until a job finishes
  • Jobs created by this script are named ScoopInstall-<packagename>.

Clone this wiki locally