Skip to content

Commit cd54940

Browse files
authored
Merge pull request #32 from bk-lg/main
Add support for reading entra id application settings from config file
2 parents c8cfbc5 + 0eb5e0a commit cd54940

File tree

4 files changed

+35
-4
lines changed

4 files changed

+35
-4
lines changed

LICENSE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
MIT License
22

33
Copyright (c) 2023 Romain
4+
Copyright (c) 2025 Lukas Glitt
45

56
Permission is hereby granted, free of charge, to any person obtaining a copy
67
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,11 @@ Winget Intune app packager
1111
![image](https://user-images.githubusercontent.com/96626929/229953293-937dc902-d1d7-4fdb-8146-03d3052a584a.png)
1212

1313
This tool auto create Intune app package from Winget app repository using https://github.com/Romanitho/Winget-Install
14+
15+
## Configuration file
16+
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:
17+
```
18+
tenant_id=
19+
client_id=
20+
redirect_uri=https://login.microsoftonline.com/common/oauth2/nativeclient
21+
```

config.env.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
tenant_id=
2+
client_id=
3+
redirect_uri=https://login.microsoftonline.com/common/oauth2/nativeclient

sources/WingetIntunePackager.ps1

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,9 @@ function Start-InstallGUI {
7575
<Grid x:Name="GridIcon" VerticalAlignment="Top" HorizontalAlignment="Right" Width="90" Height="90" Margin="0,152,10,0" Background="White">
7676
<Image x:Name="AppIcon" Height="90" Width="90" HorizontalAlignment="Center" VerticalAlignment="Center"/>
7777
</Grid>
78-
<Button x:Name="ConnectButton" Content="Connect" HorizontalAlignment="Right" VerticalAlignment="Top" Width="90" Height="24" Margin="0,330,10,0"/>
79-
<TextBlock x:Name="ConnectionStatusTextBlock" HorizontalAlignment="Left" Margin="614,359,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Text="Not connected." Foreground="Red"/>
78+
<Button x:Name="LoadConfigButton" Content="Load config" HorizontalAlignment="Right" VerticalAlignment="Top" Width="90" Height="24" Margin="0,308,10,0"/>
79+
<Button x:Name="ConnectButton" Content="Connect" HorizontalAlignment="Right" VerticalAlignment="Top" Width="90" Height="24" Margin="0,337,10,0"/>
80+
<TextBlock x:Name="ConnectionStatusTextBlock" HorizontalAlignment="Left" Margin="614,362,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Text="Not connected." Foreground="Red"/>
8081
<Label x:Name="IntuneClientID" Content="Intune Client ID:" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="10,354,0,0"/>
8182
<TextBox x:Name="IntuneClientIDTextbox" VerticalAlignment="Top" Margin="10,380,0,0" Height="24" VerticalContentAlignment="Center" Width="280" HorizontalAlignment="Left"/>
8283
<TextBox x:Name="IntuneRedirectUriTextbox" VerticalAlignment="Top" Margin="300,380,0,0" Height="24" VerticalContentAlignment="Center" Width="280" HorizontalAlignment="Left"/>
@@ -85,7 +86,6 @@ function Start-InstallGUI {
8586
</Grid>
8687
</Window>
8788
"@
88-
8989
#Create window
9090
$inputXML = $inputXML -replace 'mc:Ignorable="d"', '' -replace "x:N", 'N' -replace '^<Win.*', '<Window'
9191
[xml]$XAML = $inputXML -f $WingetIntunePackager
@@ -100,7 +100,6 @@ function Start-InstallGUI {
100100
$FormObjects | ForEach-Object {
101101
Set-Variable -Name "$($_.Name)" -Value $WingetIntunePackagerForm.FindName($_.Name) -Scope Script
102102
}
103-
104103
#Icon Dialog box
105104
$OpenIconDialog = New-Object System.Windows.Forms.OpenFileDialog
106105
$OpenIconDialog.Filter = "Image Files (*.jpg,*.jpeg,*.png)|*.jpg;*.jpeg;*.png"
@@ -187,6 +186,26 @@ function Start-InstallGUI {
187186
$AppIcon.Source = $AppInfo.Icon = $null
188187
})
189188

189+
$LoadConfigButton.add_click({
190+
#Try to load configuration
191+
try {
192+
# $ScriptPath
193+
# if ($MyInvocation.MyCommand.CommandType -eq "ExternalScript"){
194+
# $ScriptPath = Split-Path -Parent -Path $MyInvocation.MyCommand.Definition }
195+
# else {
196+
# $ScriptPath = Split-Path -Parent -Path ([Environment]::GetCommandLineArgs()[0])
197+
# if (!$ScriptPath){ $ScriptPath = "." }
198+
# }
199+
$config = Get-Content -Path .\config.env | ConvertFrom-StringData
200+
}
201+
catch {
202+
Write-Verbose "Failed to read configuration file: $_."
203+
}
204+
$IntuneTenantIDTextbox.Text = $config.tenant_id
205+
$IntuneClientIDTextbox.Text = $config.client_id
206+
$IntuneRedirectUriTextbox.Text = $config.redirect_uri
207+
})
208+
190209
$ConnectButtonAction = {
191210
Start-PopUp "Connecting..."
192211
$ConnectionStatus = Connect-MSIntuneGraph -TenantID $IntuneTenantIDTextbox.Text -ClientID $IntuneClientIDTextbox.Text -RedirectUri $IntuneRedirectUriTextbox.Text

0 commit comments

Comments
 (0)