Skip to content

Instantly share code, notes, and snippets.

@solrevdev
Created March 6, 2024 09:55
Show Gist options
  • Save solrevdev/e0b4a26bb6e6a2f7d7ab57c4e93eb99c to your computer and use it in GitHub Desktop.
Save solrevdev/e0b4a26bb6e6a2f7d7ab57c4e93eb99c to your computer and use it in GitHub Desktop.
update.ps1 - a script that i use on windows servers to keep tooling up to date
#!/usr/bin/env pwsh
Write-Output "Updates starting at $(Get-Date)"
scoop update
choco upgrade all -y
# Update .NET tools
$tools = dotnet tool list -g | Select-Object -Skip 2
foreach ($row in $tools) {
$cols = $row.Split(" ")
$tool = $cols[0]
try {
dotnet tool update -g $tool
}
catch [System.Exception] {
Write-Warning "Failed to update tool '$tool': $($_.Exception.Message)"
}
}
# VS Code Extension Update (with safety check)
if (Test-Path (Get-Command -CommandType Application -Name 'code').Path) {
code --update-extensions
}
else {
Write-Warning "Visual Studio Code does not seem to be installed or the 'code' command is not found."
}
Write-Output "Updates finished at $(Get-Date)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment