From 6c818005eee16f5e2ac92cc58cde17e3a78da70d Mon Sep 17 00:00:00 2001 From: Ivo Oskamp Date: Fri, 20 Dec 2024 22:20:10 +0100 Subject: [PATCH] Upload files to "Winget" --- Winget/winget-install.ps1 | 11 +++++++++++ Winget/winget-unistall.ps1 | 3 +++ Winget/winget-upgrade.ps1 | 23 +++++++++++++++++++++++ 3 files changed, 37 insertions(+) create mode 100644 Winget/winget-install.ps1 create mode 100644 Winget/winget-unistall.ps1 create mode 100644 Winget/winget-upgrade.ps1 diff --git a/Winget/winget-install.ps1 b/Winget/winget-install.ps1 new file mode 100644 index 0000000..0d55a8c --- /dev/null +++ b/Winget/winget-install.ps1 @@ -0,0 +1,11 @@ +#Geef de applicatie naam op bij het commmando zoals bijvoorbeeld \winget-install.ps1 thomasnordquist.MQTT-Explorer +param ($name) +#create a variable for Winget to the AppInstallerCLI and use that +################################# +# Werkt niet +# $Winget = Get-ChildItem -Path (Join-Path -Path (Join-Path -Path $env:ProgramFiles -ChildPath "WindowsApps") -ChildPath "Microsoft.DesktopAppInstaller*_x64*\AppInstallerCLI.exe") +# +#&$winget install --silent --manifest $templateFilePath +################################# + +winget install --id $name --exact --silent --accept-package-agreements --accept-source-agreements diff --git a/Winget/winget-unistall.ps1 b/Winget/winget-unistall.ps1 new file mode 100644 index 0000000..3d95d95 --- /dev/null +++ b/Winget/winget-unistall.ps1 @@ -0,0 +1,3 @@ +#Geef de applicatie naam op bij het commmando zoals bijvoorbeeld \winget-install.ps1 thomasnordquist.MQTT-Explorer +param ($name) +winget uninstall --id $name --exact --silent \ No newline at end of file diff --git a/Winget/winget-upgrade.ps1 b/Winget/winget-upgrade.ps1 new file mode 100644 index 0000000..f5fe76f --- /dev/null +++ b/Winget/winget-upgrade.ps1 @@ -0,0 +1,23 @@ +#source https://call4cloud.nl/2021/05/cloudy-with-a-chance-of-winget/ + +$content = @' +winget source remove msstore +winget source reset --force +winget upgrade --query --silent --force --accept-package-agreements --accept-source-agreements --all +'@ + + +# create custom folder and write PS script +$path = $(Join-Path $env:ProgramData CustomScripts) +if (!(Test-Path $path)) +{ +New-Item -Path $path -ItemType Directory -Force -Confirm:$false +} +Out-File -FilePath $(Join-Path $env:ProgramData CustomScripts\WingetUppgradeApps.ps1) -Encoding unicode -Force -InputObject $content -Confirm:$false + +# register script as scheduled task +$Time = New-ScheduledTaskTrigger -AtLogOn +$User = "SYSTEM" +$Action = New-ScheduledTaskAction -Execute "powershell.exe" -Argument "-ex bypass -file `"C:\ProgramData\CustomScripts\WingetUppgradeApps.ps1`"" +Register-ScheduledTask -TaskName "UpgradeApps" -Trigger $Time -User $User -Action $Action -Force +Start-ScheduledTask -TaskName "UpgradeApps"