So I have created this worklet, but nothing seem to happen when I try to run it manually on a computer. Any idea whats wrong?
Evalution:
# Runs 'winget upgrade' to dertimne any updates and save the output
$output = winget upgrade | Out-String
# looking for a specific text
if ($output -match "No applicable update found.") {
# no updates found
exit 0
} else {
# uådates found
exit 1
}
Remediation :
# Runs a elevated PowerShell session to update all
$scriptBlock = {
winget upgrade --all --silent --accept-package-agreements --accept-source-agreements
}
# Runs the script with admin priviliges
Start-Process powershell -ArgumentList "-Command", $scriptBlock -Verb RunAs