Intune Proactive Remediations + Winget.exe = Love

Описание к видео Intune Proactive Remediations + Winget.exe = Love

Intune Proactive Remediation together with winget.exe you can do fantastic things. I use this a lot at my work with great success.

Showing here how to look for all VLC installations if they are the latest versions out there and then update if not. We create a template of scripts that can in a few seconds be changed to any software that you want (the software must be found at https://winget.run but most are there).
We create two scripts, one detection script that looks if locally installed VLC is the latest, if it is not it calls the second script, the Remediation script.
Both scripts use winget.exe which already exists on newer Windows OS, so we do this with code only, no download of files or anything.

Links:
Find winget apps ID: https://winget.run

Scripts:
You can copy the two scripts below here, be careful to not but all in one script, it is two. To update another software than VLC just find the AppID of your app on the link above (winget.run)

####### Detection script ########
Software Detection Script to see if software needs an update
Author: John Bryntze
Date: 6th January 2023

Help System to find winget.exe
$JBNWinGetResolve = Resolve-Path "C:\Program Files\WindowsApps\Microsoft.DesktopAppInstaller_*_x64__8wekyb3d8bbwe\winget.exe"
$JBNWinGetPathExe = $JBNWinGetResolve[-1].Path

$JBNWinGetPath = Split-Path -Path $JBNWinGetPathExe -Parent
set-location $JBNWinGetPath

Variables
$JBNAppID = "VideoLAN.VLC"
$JBNAppFriendlyName = "VideoLAN VLC"

Check locally installed software version
$JBNLocalInstalledSoftware = .\winget.exe list -e --id $JBNAppID --accept-source-agreements

$JBNAvailable = (-split $JBNLocalInstalledSoftware[-3])[-2]

Check if needs update
if ($JBNAvailable -eq 'Available')
{
write-host $JBNAppFriendlyName "is installed but not the latest version, needs an update"
exit 1
}

if ($JBNAvailable -eq 'Version')
{
write-host $JBNAppFriendlyName "is installed and is the latest version"
exit 0
}

if (!$JBNAvailable)
{
write-host $JBNAppFriendlyName "VLC is not installed"
exit 0
}

##### Do not copy this line, below is another script #####

######## Remediation script #########
Software Remediation Script to update the software
Author: John Bryntze
Date: 6th January 2023

Help System to find winget.exe
$JBNWinGetResolve = Resolve-Path "C:\Program Files\WindowsApps\Microsoft.DesktopAppInstaller_*_x64__8wekyb3d8bbwe\winget.exe"
$JBNWinGetPathExe = $JBNWinGetResolve[-1].Path

$JBNWinGetPath = Split-Path -Path $JBNWinGetPathExe -Parent
set-location $JBNWinGetPath

Variables
$JBNAppID = "VideoLAN.VLC"

Run upgrade of the software
.\winget.exe upgrade -e --id $JBNAppID --silent --accept-package-agreements --accept-source-agreements

Комментарии

Информация по комментариям в разработке