Skip to content

Commit 38c4de8

Browse files
committed
Documentation Finished + winget-detect.ps1
1 parent 3a1ae27 commit 38c4de8

File tree

2 files changed

+74
-5
lines changed

2 files changed

+74
-5
lines changed

README.md

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -205,10 +205,25 @@ Default is 1048576 = 1 MB (ca. 7500 lines)
205205
Specify Winget-AutoUpdate installation location. Default: `C:\Program Files\Winget-AutoUpdate` (Recommended to leave default).
206206

207207
### Deploy with Intune
208-
You can use [Winget-Install](https://github.com/Romanitho/Winget-AutoUpdate/blob/main/Sources/Winget-AutoUpdate/Winget-Install.ps1) to deploy the package for example in Intune:
208+
You can use [Winget-Install](https://github.com/Romanitho/Winget-AutoUpdate/blob/main/Sources/Winget-AutoUpdate/Winget-Install.ps1) to deploy the package (this example with an override of parameters):
209209
```batch
210-
"%systemroot%\sysnative\WindowsPowerShell\v1.0\powershell.exe" -noprofile -executionpolicy bypass -file "C:\Program Files\Winget-AutoUpdate\Winget-Install.ps1" -AppIDs "Romanitho.Winget-AutoUpdate --scope machine --override \"/qn RUN_WAU=YES USERCONTEXT=1 STARTMENUSHORTCUT=1 NOTIFICATIONLEVEL=SuccessOnly UPDATESINTERVAL=Daily""
210+
"%systemroot%\sysnative\WindowsPowerShell\v1.0\powershell.exe" -noprofile -executionpolicy bypass -file "C:\Program Files\Winget-AutoUpdate\Winget-Install.ps1" -AppIDs "Adobe.Acrobat.Reader.64-bit --scope machine --override \"-sfx_nu /sAll /rs /msi EULA_ACCEPT=YES DISABLEDESKTOPSHORTCUT=1""
211211
```
212+
### Deploy with SCCM
213+
You can also use [Winget-Install](https://github.com/Romanitho/Winget-AutoUpdate/blob/main/Sources/Winget-AutoUpdate/Winget-Install.ps1) to deploy the same package in **SCCM**:
214+
```batch
215+
powershell.exe -noprofile -executionpolicy bypass -file "C:\Program Files\Winget-AutoUpdate\Winget-Install.ps1" -AppIDs "Adobe.Acrobat.Reader.64-bit --scope machine --override \"-sfx_nu /sAll /rs /msi EULA_ACCEPT=YES DISABLEDESKTOPSHORTCUT=1""
216+
```
217+
Instead of including the override parameters in the install string you can use a **Mod** (**mods\Adobe.Acrobat.Reader.64-bit-override.txt**) with the content:
218+
```batch
219+
"-sfx_nu /sAll /rs /msi EULA_ACCEPT=YES DISABLEDESKTOPSHORTCUT=1"
220+
```
221+
* A standard single installation: **-AppIDs Notepad++.Notepad++**
222+
* Multiple installations: **-AppIDs "7zip.7zip, Notepad++.Notepad++"**
223+
224+
As a detection script use **config\winget-detect.ps1** (change app to detect [**Application ID**]) in **Intune**/**SCCM** ([winget-detect.ps1](Sources/Winget-AutoUpdate/config/winget-detect.ps1))
225+
226+
A nice feature is if you're already using the deprecated standalone script **winget-install.ps1** from the [old repo](https://github.com/Romanitho/Winget-Install) and have placed it somwhere locally on all clients you can make a **SymLink** in its place and keep using the old path (avoiding a lot of work) in your deployed applications (**Winget-Install.ps1** takes care of the SymLink logic).
212227

213228
## GPO / Intune Management
214229
Read more in the [Policies section](https://github.com/Romanitho/Winget-AutoUpdate/tree/main/Sources/Policies).
@@ -221,6 +236,8 @@ If **ExitCode** is **1** from `_WAU-mods.ps1` then **Re-run WAU**.
221236

222237
Likewise `_WAU-mods-postsys.ps1` can be used to do things at the end of the **SYSTEM context WAU** process before the user run.
223238

239+
You can find more information in [README Mods for WAU](Sources/Winget-AutoUpdate/mods/README.md)
240+
224241
## Custom scripts (Mods feature for Apps)
225242
The Mods feature allows you to run additional scripts when upgrading or installing an app.
226243
Just put the scripts in question with the **AppID** followed by the `-preinstall`, `-upgrade`, `-install`, `-installed` or `-notinstalled` suffix in the **mods** folder.
@@ -237,16 +254,15 @@ The **-install** mod will be used for upgrades too if **-upgrade** doesn't exist
237254
> Example:<br>
238255
If you want to run a script that removes the shortcut from **%PUBLIC%\Desktop** (we don't want to fill the desktop with shortcuts our users can't delete) just after installing **Acrobat Reader DC** (32-bit), prepare a powershell script that removes the Public Desktop shortcut **Acrobat Reader DC.lnk** and name your script like this: `Adobe.Acrobat.Reader.32-bit-installed.ps1` and put it in the **mods** folder.
239256

240-
You can find more information on [Winget-Install Repo](https://github.com/Romanitho/Winget-AutoUpdate?tab=readme-ov-file#custom-script-mods-for-wau), as it's a related feature.<br>
241-
Read more in the `README.md` under the directory **mods**.
257+
You can find more information in [README Mods for WAU](Sources/Winget-AutoUpdate/mods/README.md), as it's a related feature.
242258

243259
Share your mods with the community:<br>
244260
<https://github.com/Romanitho/Winget-AutoUpdate/discussions/categories/mods>
245261

246262
### Winget native parameters
247263
Another finess is the **AppID** followed by the `-override` suffix as a **text file** (.**txt**) that you can place under the **mods** folder.
248264
> Example:<br>
249-
**Canneverbe.CDBurnerXP-override.txt** with the content `ADDLOCAL=All REMOVE=Desktop_Shortcut /qn`
265+
**Adobe.Acrobat.Reader.64-bit-override.txt** with the content `"-sfx_nu /sAll /rs /msi EULA_ACCEPT=YES DISABLEDESKTOPSHORTCUT=1"`
250266

251267
This will use the **content** of the text file as a native **winget --override** parameter when upgrading (as proposed by [JonNesovic](https://github.com/JonNesovic) in [Mod for --override argument #244](https://github.com/Romanitho/Winget-AutoUpdate/discussions/244#discussion-4637666)).
252268

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#Change app to detect [Application ID]
2+
$AppToDetect = "Notepad++.Notepad++"
3+
4+
5+
<# FUNCTIONS #>
6+
7+
Function Get-WingetCmd {
8+
9+
$WingetCmd = $null
10+
11+
#Get WinGet Path
12+
try {
13+
#Get Admin Context Winget Location
14+
$WingetInfo = (Get-Item "$env:ProgramFiles\WindowsApps\Microsoft.DesktopAppInstaller_*_8wekyb3d8bbwe\winget.exe").VersionInfo | Sort-Object -Property FileVersionRaw
15+
#If multiple versions, pick most recent one
16+
$WingetCmd = $WingetInfo[-1].FileName
17+
}
18+
catch {
19+
#Get User context Winget Location
20+
if (Test-Path "$env:LocalAppData\Microsoft\WindowsApps\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\winget.exe") {
21+
$WingetCmd = "$env:LocalAppData\Microsoft\WindowsApps\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\winget.exe"
22+
}
23+
}
24+
25+
return $WingetCmd
26+
}
27+
28+
<# MAIN #>
29+
30+
#Get WinGet Location Function
31+
$winget = Get-WingetCmd
32+
33+
#Set json export file
34+
$JsonFile = "$env:TEMP\InstalledApps.json"
35+
36+
#Get installed apps and version in json file
37+
& $Winget export -o $JsonFile --accept-source-agreements | Out-Null
38+
39+
#Get json content
40+
$Json = Get-Content $JsonFile -Raw | ConvertFrom-Json
41+
42+
#Get apps and version in hashtable
43+
$Packages = $Json.Sources.Packages
44+
45+
#Remove json file
46+
Remove-Item $JsonFile -Force
47+
48+
# Search for specific app and version
49+
$Apps = $Packages | Where-Object { $_.PackageIdentifier -eq $AppToDetect }
50+
51+
if ($Apps) {
52+
return "Installed!"
53+
}

0 commit comments

Comments
 (0)