2024 - Learn package Apps in Microsoft Intune like an expert - become a hero at work!
Вставка
- Опубліковано 5 лип 2024
- You will learn how to package any application in the Winget.exe repository (and there are many) to always have the latest version without repackaging each new release.
No previous skills are needed. Just need to follow along! This is a skill you must know about in 2024.
We will be writing PowerShell scripts called Winget.exe to install and uninstall our software of choice, in this video, we chose Microsoft SQL Management Studio, but you can replace only two words in the scripts and change to any software you want (you need to know the Winget ID of the software but we show how to find that also).
We will also write a detection script, again with the help of winget.exe
Let's get started and thanks for watching!
Links:
github.com/Microsoft/Microsof...
3 SCRIPTS from the video ###
Install-MicrosoftSQLManagementStudioLATESTx86.ps1 - COPY the below ##
Install the latest Microsoft SQL Management Studio from Winget repository
Author: John Bryntze
Date: 2nd February 2024
set variables
$JBNWingetAppID = "Microsoft.SQLServerManagementStudio"
Help SYSTEM find winget.exe folder
Set-Location -Path ("$env:ProgramW6432\WindowsApps\Microsoft.DesktopAppInstaller_*_x64__8wekyb3d8bbwe")
Install Microsoft SQL Management Studio software with winget.exe
.\winget.exe install -e --id $JBNWingetAppID --silent --accept-package-agreements --accept-source-agreements --force
Uninstall-MicrosoftSQLManagementStudiox86.ps1 COPY the below ##
Uninstall the latest Microsoft SQL Management Studio from Winget repository
Author: John Bryntze
Date: 2nd February 2024
set variables
$JBNWingetAppID = "Microsoft.SQLServerManagementStudio"
Help SYSTEM find winget.exe folder
Set-Location -Path ("$env:ProgramW6432\WindowsApps\Microsoft.DesktopAppInstaller_*_x64__8wekyb3d8bbwe")
Install Microsoft SQL Management Studio software with winget.exe
.\winget.exe Uninstall -e --id $JBNWingetAppID --silent --accept-source-agreements --force
DetectionScriptMicrosoftSQLManagementStudio.ps1 COPY the below ##
Purpose: Checking that locally installed Microsoft SQL Management Studio is equal or greater to the latest found online
Author: John Bryntze
Date: 2nd February 2024
set variables
$JBNWingetAppID = "Microsoft.SQLServerManagementStudio"
Help SYSTEM find winget.exe folder
Set-Location -Path ("$env:ProgramW6432\WindowsApps\Microsoft.DesktopAppInstaller_*_x64__8wekyb3d8bbwe")
What is the latest version online
$JBNSearch = .\winget.exe search -e --id $JBNWingetAppID --accept-source-agreements
$JBNOnlineVersion = (-split $JBNSearch[-1])[-2]
What is the version installed
$JBNLocalSearch = .\winget.exe list -e --id $JBNWingetAppID
#If not installed exit here...
if($JBNLocalSearch[-1] -eq 'No installed package found matching input criteria.')
{
exit 1
#no Microsoft SQL Management Studio is installed...
}
Check if the installed version has a newer version on the web...
$JBNCheckIfAvailavbleExist = (-split $JBNLocalSearch[-3])[-2]
if($JBNCheckIfAvailavbleExist -eq "Available")
{
$JBNLocalVersion = (-split $JBNLocalSearch[-1])[-3]
}
else
{
$JBNLocalVersion = (-split $JBNLocalSearch[-1])[-2]
}
if($JBNLocalVersion -ge $JBNOnlineVersion)
{
Write-Output "The Device got the latest version installed."
exit 0
#Detection success
}
else
{
exit 1
#Detection failed
}
Chapters
00:00:00 Introduction
00:08:25 Package, folder, files, Intunewin file, PowerShell...
00:27:27 Intune Console creating the Win32 App
00:43:03 Install from Company Portal
00:47:10: Outro
Great video thanks very much.
Thank you very much for this nice comments, those gives me energy to do more videos
Wow! Great video John!!
Thanks, I have covered most of this video in parts of other video, but this one is maybe the most complete. I think anyone who package apps for Windows in Intune should learn these steps and use them when possible. So nice to package ONCE and then you know the package will always install the latest versions for years to come :)
Really helpful, appreciate each second you share ❤
Thank you very much Ahmed, appreciate your comment.
Always the best!
it works great, I have been using this method for several months for many applications that needs frequent update.
Well done Anbarasan, happy to hear! yes it is a real time saver, package once and then move on to next. When package static MSI which is good also, but in w few weeks/months the package is already old
Hi John, great job with the video, you really explain the steps carefully so its easy to understand. I would like also like to see the remediation script to keep the application updated. :)
Thanks a lot Morten, here is the DETECTION SCRIPT
### Runs as Dection script if Microsoft SQL Server Management Studio is installed
### Author: John Bryntze
### Date: 3rd January 2023
# Help SYSTEM find winget.exe folder
Set-Location -Path ("$env:ProgramW6432\WindowsApps\Microsoft.DesktopAppInstaller_*_x64__8wekyb3d8bbwe")
## Check if there is an avilable update
$LocalInstall = .\winget.exe list -e --id Microsoft.SQLServerManagementStudio --accept-source-agreements
# split the output and take the third row from the end [-3] and second from right [-2] is Avaiable we know there is an update (and that Firefox is installed)
$AvailableUpdate = (-split $LocalInstall[-3])[-2]
if($AvailableUpdate -eq 'Available')
{
write-host "Microsoft SQL Server Management Studio is installed and needs an update..."
exit 1
}
if(!$AvailableUpdate)
{
write-host "Microsoft SQL Server Management Studio is not installed on this system..."
exit 0
}
if($AvailableUpdate -eq 'Version')
{
write-host "Microsoft SQL Server Management Studio is installed on this system and with the latest version..."
exit 0
}
And here is the REMEDIATION Script
### Update to the latest Microsoft SQL Server Management Studio
### Author: John Bryntze
### Date: 3rd January 2023
# Help SYSTEM find winget.exe folder
Set-Location -Path ("$env:ProgramW6432\WindowsApps\Microsoft.DesktopAppInstaller_*_x64__8wekyb3d8bbwe")
## Update Git with winget.exe
.\winget.exe upgrade -e --id Microsoft.SQLServerManagementStudio --silent --accept-package-agreements --accept-source-agreements
@@IntuneVitaDoctrina This is great. I can use this for all apps we install with winget that is not in the new store (but i guess the new store will get more and more apps over time).
yes, the store is great, but also with a script you can copy in custom files and reg edit which you cannot with store so it will always be easier to customize this way, But if just need the app and no settings, then store apps is probably the future
As always great explaination! Still struggling with writing my own scripts though ^^.
What will happen if you delete the original .intunewin file and replace it with the edited .intunewin? Does this has any impact on device(s)?
Please keep on uploading!
Thanks a lot, if you replace the original .intunewin with a new it will keep the same package ID but get a sort of version to it, like _2 and it will run again if detection rule allows.
All good? Could you explain to me how you do it in the case of Java for x32 and x64 versions, is there a way to identify the different versions?
thanks all good, hope you too.
You can specify a switch called: --architecture (or just a) and then if you want 32 bit or 64 bit, if it comes only in 64-bit it will ignore this flag.
from another video when showing this:
## Install Oracle Java 32-bit software with winget.exe
.\winget.exe install -e --id $JBNWingetAppID --architecture=x86 --silent --accept-package-agreements --accept-source-agreements
If you want the full video check here: ua-cam.com/video/nXOdyZcTjWI/v-deo.html&ab_channel=Intune%26VitaDoctrina
@@IntuneVitaDoctrina thanks!!! ❤
The error below has already occurred, could anyone help me?
"Falha na pesquisa da origem: winget
Ocorreu um erro inesperado ao executar o comando:
0x8a15000f : Os dados exigidos pela origem estão ausentes"
See others have this issue, some fixed it here:
learn.microsoft.com/en-us/answers/questions/1256882/winget-gives-0x8a15000f-error-for-all-applications
.... and now to Autopilot, how to make sure that winget is actually a dependency for all apps that were packaged this way ;-) Can be added as a dependency, or winget needs to be added as a blocking app in ESP and make sure that all of these packaged apps have a prereq - for the machine to be PAST OOBE :)
you got really good questions (= difficult questions LOL but GOOD!) yes winget is not good for Autopilot unfortunately, better for self service apps or update existing apps already installed. ESP blocking apps isn't so useful, because it will still to run all apps randomly but only present desktop to user once they have installed, so it could result Autopilot error out or user has to wait hours to see desktop.
your idea a prereq would work fine, good idea, same, user will have to wait a bit to see apps.
I hope with Windows 12 (release in 2025) winget gets more integrated into the OS itself and be better for Autopilot.
Great video, but I can't get the detection script to show it as installed in the company portal or have the uninstall option
Found the error, It was a # that was missing on one line :-(
Thanks for letting me know, and GREAT that you fixed it, well done!
FYI: have the same crash with intunewin as you. I need to be in admin cmd or terminal as well.
ah so it is not only me, thanks for letting know!
Excellent video!! 👍, if the deploy is required if a new version is released it will be updated automatically?
Thanks a lot Matt, it will install the latest at that time. To ensure it stays upgraded to latest after install you can use nearly same scripts but using Remediation script and have them run like once a week, if no upgrade it does nothing and if an upgrade it get it every week. I got a video showing this, think I called it vulnerability hunting, if you want the scripts I use for it let me know and I post here in the comments when I can
Thanks, I will try to make them (if I have problems I will let you know). Thanks! again
But from what I see on the detection script it should keep auto updating the app when it detect it is not the latest version so why would we need remediation script? Excellent job btw !
@@IntuneVitaDoctrina , very innovative approach and surely IME will try to install the app as soon as the detection script exits with code 1. Am I missing something?
@@zak.premium That's what I thought. I'm dissecting the script to understand it better, and my understanding is that as soon as the script exits with code 1 Intune/IME, I will try to install the app again. Need to lab this out.
Hi John,
Does that mean this works similar to the Intune new capability called "Windows Catalog app (Win32)" or its something else?
Hi, I would say it is something else, the Windows Catalog App (Win32) is limited to what Microsoft pre-package for you, at todays date it is 100 apps, and they are not in Winget format, even their FAQ mention this: learn.microsoft.com/en-us/mem/intune/apps/apps-enterprise-app-management#frequently-asked-questions-faq
"Does Enterprise App Management use Winget?
No. Enterprise App Catalog apps are directly installed by the Intune management extension (IME)."
So different things, I got a video about Enterprise App Catalog: ua-cam.com/video/U2xOY5DYHk4/v-deo.html&ab_channel=Intune%26VitaDoctrina
@@IntuneVitaDoctrina
another question;
If we use winget for apps deployment does that mean those deployed apps would be auto updating when there is new update/version is available from respective vendors or what?
Also what all apps we can use with this winget cmdlets?
Correct they will auto update when vendors update in the winget repository :) so you package once and you are good :)
Winget got one drawback, if you run autopilot it is not always ready so it can delay for installations, it will get there but users have to wait too long, so I prefer Winget for Self Service software, or for existing devices, not newly enrolled :)
you can search all the apps, I would say nearly all exists there, not all works exactly as I want, for example TeamViewer works but doesn't assign correctly so still MSI package that one for exampke. Do a: winget search --id A and you get all packages with A etc... Winget got a lot! :) hope that helps
@@IntuneVitaDoctrina
But I think it would be easy and will work for those devices which would be enrolled via Intune autopilot for example: I have deployed an app with 19.2 version and later it was updated to 20.1 version then will it work or not because as its going to deploy the app on device when and whatever was available via Intune during the autopilot enrollment?
What do you say about this?
Another question below
Who is owner of Winget and who does update it with latest patches of apps if we are using the winget for apps deployment via Intune as I know the use case of it but wanted to make sure the apps which are part of winget those are always updated and who is taking ownership of them?
JB, it's great but I still can't get it to work. in my environment I have the microsoft public store blocked. I always get the same error. error from script =Cannot index into a null array.
At C:\Program Files (x86)\Microsoft Intune Management
Extension\Content\DetectionScripts\1e08c5da-e5cb-4024-bb83-1932ee58e29e_1.ps1:9 char:1
+ $JBNOnlineVersion = (-split $JBNSearch[-1])[-2]
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : NullArray
even if disable Microsoft Public Store it should work, if you just block the app or you block more than that?
If you just open a cmd.exe and type:
winget.exe
Do you get any output?
As administrator not when executing Winget it comes out that it does not exist. but as normal user if. validating the route "C:\Program FilesWindowsApps Microsoft.DesktopAppInstaller_*_x64__8wekyb3d8bbwe as adminsitrador this the file winget.exe. @@IntuneVitaDoctrina
As administrator not when executing Winget it comes out that it does not exist. but as normal user if. validating the route "C:\Program FilesWindowsApps Microsoft.DesktopAppInstaller_*_x64__8wekyb3d8bbwe as adminsitrador this the file winget.exe. .. Error Error al ejecutar el programa 'winget.exe': Acceso denegadoEn línea: 12 Carácter: 27
+ ... dSoftware = .\winget.exe list -e --id $AppID --accept-source-agreemen ...@@IntuneVitaDoctrina
I see one errors, it is missing a '\' between:
"C:\Program Files
AND
WindowsApps Microsoft.DesktopAppInstaller_*_x64__8wekyb3d8bbwe
Check if it is not missing there and it could be it
@@IntuneVitaDoctrina I can't get it to work any time. I have three virtual machines, one works, the other two don't. If you install it from PowerShell directly everything works. but it doesn't work from the company portal. :(