winget+.ps1
is a PowerShell script that provides enhanced package updating capabilities for Windows Package Manager winget with a convenient alias wup.
- Updates packages using either full package ID or name fallback
- Supports single and multiple package updates
- Works with or without quotes for package names
- easier usage: it is way shorter to type
wupalias instead ofwinget <command> - debug option: you can use
-Debugswitch to see what is happening under the hood
Save the winget+.ps1 script to a permanent location.
Add the alias to your PowerShell profile:
# Open your PowerShell profile
notepad $PROFILE
# Add this line (adjust the path to where you saved winget+.ps1):
Set-Alias wup "C:\Path\To\winget+.ps1"# Check available updates
wup
# then you could copy packages IDs from winget output and paste to update them like next examples do
# Update single package
wup pnpm.pnpm
# Update multiple packages
wup pnpm.pnpm yarn.yarn nodejs.nodejs
# Update using array
$apps = @("Microsoft.PowerToys", "Mozilla.Firefox")
wup -Packages $appsYou can add the -Verbose switch to see detailed execution information:
# See detailed execution steps
wup pnpm.pnpm -Verbosewup does not support pipelines so you can not use it like so:
```powershell
winget list | wup
```
but possible you can rewrite this script to support pipelines
TODO: the only thing is to re-concile with ValueFromRemainingArguments = $true that could make script way bigger
# draft for pipeline feature
[CmdletBinding()]
param(
[Parameter(ValueFromPipeline = $true,
ValueFromPipelineByPropertyName = $true,
Position = 0)]
[string[]]$Packages,
[Parameter()]
[switch]$Install
)
begin {
$packagesToProcess = @()
}
process {
if ($_ -is [string]) {
$packagesToProcess += $_
}
elseif ($Packages) {
$packagesToProcess += $Packages
}
}
end {
foreach ($package in $packagesToProcess) {
if ($Install) {
Write-Verbose "Installing package: $package"
winget install $package
}
else {
Write-Verbose "Updating package: $package"
# Original update logic here
}
}
}Also, note that important --id argument have to be in form packageName.SomeOtherPArt that is most cases but not always, so in these rare cases script will fails as it do simple regex operation to extract package name. probably you could improve script by adding function that relying on winget show command to get package name, this addition will complicate script too
# Function to get package name from winget
# draft
function Get-WingetPackageName {
param(
[Parameter(Mandatory = $true)]
[string]$PackageId
)
try {
Write-Verbose "Getting package details for $PackageId"
$output = & winget show --id $PackageId --accept-source-agreements 2>&1
if ($LASTEXITCODE -eq 0) {
# Extract Name field from winget show output
$name = $output | Where-Object { $_ -match '^Name:' } | ForEach-Object { ($_ -split ':\s*')[1] }
Write-Verbose "Found package name: $name"
return $name
}
else {
Write-Verbose "Winget show failed, falling back to ID parsing"
return ($PackageId -split '\.')[0]
}
}
catch {
Write-Verbose "Error getting package name: $_"
return ($PackageId -split '\.')[0]
}
}
# Usage in main code
$packageName = Get-WingetPackageName -PackageId $package
- Windows Package Manager (winget) installed
- PowerShell 5.1 or higher
This project is licensed under the MIT License - see the MIT License for details.