Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/Create_New_Version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ jobs:
github_token: ${{ secrets.GITHUB_TOKEN }}

- name: Update Powershell Version
#Replace line 12 with new version
run: sed -i '12s/.*/$Script:WingetIntunePackager = "${{ steps.versioning.outputs.version }}"/g' sources/WingetIntunePackager.ps1
#Replace line 14 with new version
run: sed -i '14s/.*/$Script:WingetIntunePackager = "${{ steps.versioning.outputs.version }}"/g' sources/WingetIntunePackager.ps1

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in the latest commit. The sed command now matches the $Script:WingetIntunePackager variable name pattern rather than a hard-coded line number, so it stays correct regardless of file layout changes.


- name: Commit & Push
uses: actions-js/push@v1.4
Expand Down
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@ Winget Intune app packager

This tool auto create Intune app package from Winget app repository using https://github.com/Romanitho/Winget-Install

## Prerequisites

Before using the tool, you must create an app registration in Entra:

1. Open the **Microsoft Entra admin center**
1. In Microsoft Entra admin center, click **App registrations**.
1. In App registrations, click **New registration**.
1. In Register an application, enter a **Name**, e.g., *WingetIntunePackager*. Leave **Supported account types** set to **Single tenant only**. Under **Redirect URI (optional)**, select **Public client/native (mobile & desktop)** and enter **https://login.microsoftonline.com/common/oauth2/nativeclient**. Click **Register**

On the **Overview** page, you will find the necessary information for the configuration file (see below).

## Configuration file
You can place an configuration file with the name config.env in the same folder as the executable. The configuration file should be in the following format:
```
Expand Down
88 changes: 65 additions & 23 deletions sources/WingetIntunePackager.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ Package Winget App to Intune with Winget-Install
https://github.com/Romanitho/Winget-Intune-Packager
#>

#Requires -PSEdition Desktop

### APP INFO ###

#Winget Intune Packager version
$Script:WingetIntunePackager = "1.2.2"
$Script:WingetIntunePackager = "1.2.3"
#Winget-Install Github Link
$Script:WIGithubLink = "https://github.com/Romanitho/Winget-Install/archive/refs/tags/v1.11.3.zip"
#Winget Intune Packager Icon Base64
Expand Down Expand Up @@ -210,6 +212,18 @@ function Start-InstallGUI {

$ConnectButtonAction = {
Start-PopUp "Connecting..."
if (
[string]::IsNullOrWhiteSpace($IntuneTenantIDTextbox.Text) `
-or [string]::IsNullOrWhiteSpace($IntuneClientIDTextbox.Text) `
-or [string]::IsNullOrWhiteSpace($IntuneRedirectUriTextbox.Text)
) {
$ConnectionStatusTextBlock.Foreground = "Red"
$ConnectionStatusTextBlock.Text = "Please fill in all fields."
$ConnectionStatusTextBlock.Tag = $null
$CreateButton.IsEnabled = $false
Close-PopUp
return
}
$ConnectionStatus = Connect-MSIntuneGraph -TenantID $IntuneTenantIDTextbox.Text -ClientID $IntuneClientIDTextbox.Text -RedirectUri $IntuneRedirectUriTextbox.Text
if ($ConnectionStatus.ExpiresOn) {
$ConnectionStatusTextBlock.Foreground = "Green"
Expand Down Expand Up @@ -271,20 +285,27 @@ function Start-InstallGUI {
"AllowAvailableUninstall" = $AllowUninstallCheckbox.IsChecked
"InstallExperience" = $InstallUserContext
}
Invoke-IntunePackage $Win32AppArgs
$AppInfo = @()
$SearchTextBox.Text = ""
$IDComboBox.Text = ""
$IDComboBox.Items.Clear()
$VersionTextBox.Text = ""
$OverrideTextBox.Text = ""
$IntuneDescriptionTextBox.Text = ""
$WhitelistCheckbox.IsChecked = $false
$AllowUninstallCheckbox.IsChecked = $false
$InstallUserContextCheckbox.IsChecked = $false
$CreateButton.IsEnabled = $false
$AppIcon.Source = $null
Close-PopUp
Invoke-IntunePackage $Win32AppArgs -WarningVariable warning

if ([string]::IsNullOrEmpty($warning)) {
$AppInfo = @()
$SearchTextBox.Text = ""
$IDComboBox.Text = ""
$IDComboBox.Items.Clear()
$VersionTextBox.Text = ""
$OverrideTextBox.Text = ""
$IntuneDescriptionTextBox.Text = ""
$WhitelistCheckbox.IsChecked = $false
$AllowUninstallCheckbox.IsChecked = $false
$InstallUserContextCheckbox.IsChecked = $false
$CreateButton.IsEnabled = $false
$AppIcon.Source = $null
Close-PopUp
}

if (-not [string]::IsNullOrEmpty($warning)) {
Start-PopUp ($warning -join "`n")
}
Comment on lines +288 to +308

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in the latest commit. Both checks now use PowerShell truthiness (if (-not $warning) / if ($warning)), and @($warning) -join is used to safely handle arrays of warning messages.

})

$GithubLinkLabel.Add_PreviewMouseDown({
Expand Down Expand Up @@ -329,7 +350,7 @@ Function Start-PopUp ($Message) {
$PopUpWindow.Icon = $IconBase64

#Store Form Objects In PowerShell
$XAML.SelectNodes("//*[@Name]") | foreach {
$XAML.SelectNodes("//*[@Name]") | ForEach-Object {
Set-Variable -Name "$($_.Name)" -Value $PopUpWindow.FindName($_.Name) -Scope Script
}

Expand Down Expand Up @@ -519,12 +540,27 @@ function Get-WingetAppInfo ($AppID, $AppVersion) {

#Get Google Image app icon
$SearchImageUrl = "https://www.google.com/search?tbm=isch&q=$($AppInfo.PackageName.replace('.','+'))+logo"
$IconUrl = ((Invoke-WebRequest -Uri $SearchImageUrl).Images | Select -ExpandProperty src)[1]
$AppInfo.Icon = "$Location\$($AppInfo.ID).jpg"
Invoke-WebRequest -Uri $IconUrl -OutFile $($AppInfo.Icon)
$images = (Invoke-WebRequest -Uri $SearchImageUrl -UseBasicParsing).Images
if ($images.Count -gt 1) {
$IconUrl = ($images | Select-Object -ExpandProperty src)[1]
}
if (-not [string]::IsNullOrEmpty($IconUrl)) {
$AppInfo.Icon = "$Location\$($AppInfo.ID).jpg"
try {
Invoke-WebRequest -Uri $IconUrl -OutFile $AppInfo.Icon -UseBasicParsing
}
catch {
$AppInfo.Icon = $null
}
}
}

function Invoke-IntunePackage ($Win32AppArgs) {
function Invoke-IntunePackage () {
[CmdletBinding()]
param (
$Win32AppArgs
)

# Package .intunewin file
if (!(Test-Path "$Location/Winget-Install*")) {
Get-GithubRepository $WIGithubLink
Expand All @@ -550,7 +586,10 @@ function Invoke-IntunePackage ($Win32AppArgs) {
$DetectionRule = New-IntuneWin32AppDetectionRuleScript -ScriptFile "$DetectionScriptPath\$DetectionScriptFile"

# Convert image file to icon
$Icon = New-IntuneWin32AppIcon -FilePath $AppInfo.Icon

if ($AppInfo.Icon) {
$Icon = New-IntuneWin32AppIcon -FilePath $AppInfo.Icon
}

# Add parameters to table for the Win32 app
$Win32AppArgs.DisplayName = $AppInfo.PackageName
Expand All @@ -574,7 +613,10 @@ function Invoke-IntunePackage ($Win32AppArgs) {
$Win32AppArgs.Icon = $Icon
}

Add-IntuneWin32App @Win32AppArgs
Add-IntuneWin32App @Win32AppArgs -WarningVariable warning -WarningAction SilentlyContinue
$warning | ForEach-Object {
Write-Warning $_
}
}

function Get-WIPLatestVersion {
Expand Down Expand Up @@ -668,7 +710,7 @@ function Get-WIPLatestVersion {
Start-PopUp "Starting..."

# IntuneWin32App module needed
$IntuneWin32App = Get-InstalledModule "IntuneWin32App" -RequiredVersion $IntuneWin32AppVers -ErrorAction SilentlyContinue
$IntuneWin32App = Get-Module "IntuneWin32App" -ListAvailable | Where-Object { $PSItem.Version -eq $IntuneWin32AppVers }
if (!$IntuneWin32App) {
$NuGet = Get-PackageProvider -name "nuget" -ListAvailable -ErrorAction SilentlyContinue
if (!$NuGet) {
Expand Down