Post

Intune: Scripts and Remediations - Update software

image


Ref:

[Winget UpdatesProactive Remediations](https://scloud.work/winget-updates-proactive-remediations-2/)

Link


Task 1 Find the list id of the application

1
winget list -?
  • use the https://winget.run
  • enter the application name
1
2
3
winget install -e --id Zoom.Zoom

winget list -e --id Zoom.Zoom --accept-source-agreements

img

Task2 Powershell - Detection and Remediation Script

Test

1
2
check locally installed Zoom
$localInstalled_software = winget.exe list -e --id Zoom.Zoom --accept-source-agreements

Logic


  • If result contain Avaliable, the application needs to upgrade the version
  • If result only contain Version, the application is the latest version
  • If result don’t show anything, the application is not installed
1
2
3
-3 : line of the header

-2 : "Available" header
1
2
$available= (-split $localInstalled_software[-3])[-2]
Write-Host $available

Result

1
2
3
Name Id        Version     Available    Source
----------------------------------------------
Zoom Zoom.Zoom < 5.12.8964 5.17.7.31859 winget
  • remediation scripts will run with exit 1 from detection script

img

img

  • As Intune is run the script as System.
  • use PsExec64.exe -i -s cmd.exe

img

img

img

  • Intune>Devices>Windows>Scripts and remediations location

img

  • The script needs to save as UTF-8 format

img

  • Create the script below.

img

This post is licensed under CC BY 4.0 by the author.