From 90c1d106e19e36951081f05aa228c463122bd215 Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Wed, 1 Feb 2023 21:39:40 +0100 Subject: [PATCH] Install winget AppID from Mods Template/Functions --- Winget-AutoUpdate/mods/_AppID-template.ps1 | 7 +++++++ Winget-AutoUpdate/mods/_Mods-Functions.ps1 | 9 ++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Winget-AutoUpdate/mods/_AppID-template.ps1 b/Winget-AutoUpdate/mods/_AppID-template.ps1 index 4bbd952..b1344cf 100644 --- a/Winget-AutoUpdate/mods/_AppID-template.ps1 +++ b/Winget-AutoUpdate/mods/_AppID-template.ps1 @@ -59,6 +59,10 @@ $ReplaceText = '' #Grant "Modify" for directory/file to "Authenticated Users" - multiple: "dir1","dir2" $GrantPath = @("") +#Install App from Winget Repo, multiple: "appID1","appID2". Example: +#$AppID = @("Microsoft.PowerToys") +$AppID = @("") + #App to Run (as current logged-on user) $RunUser = "" $User = $True @@ -100,6 +104,9 @@ if ($File -and $FindText -and $ReplaceText) { if ($GrantPath) { Grant-ModsPath $GrantPath } +if ($AppID) { + Install-ModsApp $AppID +} if ($RunUser) { Invoke-ModsApp $RunUser "" "" $User } diff --git a/Winget-AutoUpdate/mods/_Mods-Functions.ps1 b/Winget-AutoUpdate/mods/_Mods-Functions.ps1 index 607d3d0..054e331 100644 --- a/Winget-AutoUpdate/mods/_Mods-Functions.ps1 +++ b/Winget-AutoUpdate/mods/_Mods-Functions.ps1 @@ -152,7 +152,6 @@ function Uninstall-ModsApp ($App) { } Return } - function Remove-ModsLnk ($Lnk) { foreach ($link in $Lnk) { @@ -230,3 +229,11 @@ function Grant-ModsPath ($GrantPath) { } Return } + +function Install-ModsApp ($AppID) { + foreach ($app in $AppID) + { + & $Winget install --id $app --accept-package-agreements --accept-source-agreements -h + } + Return +}