@@ -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