Upload files to "Winget"

This commit is contained in:
Ivo Oskamp 2024-12-20 22:20:10 +01:00
parent fa3f1fd900
commit 6c818005ee
3 changed files with 37 additions and 0 deletions

11
Winget/winget-install.ps1 Normal file
View File

@ -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

View File

@ -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

23
Winget/winget-upgrade.ps1 Normal file
View File

@ -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"