50 lines
1.2 KiB
PowerShell
50 lines
1.2 KiB
PowerShell
param(
|
|
[switch]$elevated,
|
|
[switch]$CleanOnly
|
|
)
|
|
|
|
if (-not $CleanOnly -and -not $elevated) {
|
|
winget upgrade --all --include-unknown
|
|
}
|
|
|
|
if ((Get-Command "scoop" -ErrorAction SilentlyContinue) -and -not $elevated) {
|
|
if (-not $CleanOnly) {
|
|
scoop update
|
|
scoop update --all
|
|
scoop cleanup --al
|
|
}
|
|
scoop cache rm *
|
|
}
|
|
|
|
# If not in an Administrator environment
|
|
If (-not (New-Object Security.Principal.WindowsPrincipal $(
|
|
[Security.Principal.WindowsIdentity]::GetCurrent()
|
|
)).IsInRole(
|
|
[Security.Principal.WindowsBuiltinRole]::Administrator
|
|
)
|
|
) {
|
|
# and elevating hasn't already been tried
|
|
if (-not $elevated) {
|
|
# attempt to become Administrator by re-invoking this script
|
|
Start-Process PowerShell -Verb RunAs -ArgumentList (
|
|
'-file "{0}" -elevated' -f ($MyInvocation.MyCommand.Definition)
|
|
)
|
|
}
|
|
# otherwise just exit.
|
|
exit
|
|
}
|
|
|
|
|
|
if (-not $CleanOnly) {
|
|
if (-not (Get-Command "Get-WindowsUpdate")) {
|
|
Install-Module PSWindowsUpdate
|
|
}
|
|
Get-WindowsUpdate -AcceptAll -Install
|
|
}
|
|
|
|
if (Get-Command "bleachbit" -ErrorAction SilentlyContinue) {
|
|
# Clean everything selected in the UI last time it was run.
|
|
# So... run The UI to set things up initially.
|
|
bleachbit --preset --clean
|
|
}
|