marli-Cleoni.ps1
function marli-cleoni { $Version = '0.207' #created by Marco Lippert # --------------------------- import-module $PSScriptRoot\Modul_Cleoni_Download.psm1 -force import-module $PSScriptRoot\Modul_Cleoni_Compare.psm1 -force import-module $PSScriptRoot\Modul_Cleoni_Search.psm1 -force import-module $PSScriptRoot\Modul_Cleoni_Package.psm1 -force #region - GUI Content #XAML Code kann zwischen @" und "@ ersetzt werden: [xml]$xaml = @" <Window x:Class="MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:Cleoni_Intune" mc:Ignorable="d" Title="Cleoni-Intune - $Version" Height="486" Width="1117" WindowStartupLocation="CenterScreen" ResizeMode="CanMinimize" SizeToContent="WidthAndHeight"> <Window.TaskbarItemInfo> <TaskbarItemInfo/> </Window.TaskbarItemInfo> <TabControl VerticalAlignment="Stretch" HorizontalAlignment="Stretch"> <TabItem Header="Reports" Name="Tab_Reports"> <TabControl VerticalAlignment="Stretch" HorizontalAlignment="Stretch"> <TabItem Header="Download" Name="Tab_Download"> <Grid Background="LightGray" HorizontalAlignment="Left" VerticalAlignment="Top" Height="328" Width="601"> <Grid.RowDefinitions> <RowDefinition Height="Auto"/> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto"/> </Grid.ColumnDefinitions> <GroupBox Header="Download-Path" Margin="10,10,144,293"> <DockPanel HorizontalAlignment="Stretch"> <TextBox TextWrapping="NoWrap" Text="" Width="317" Name="txt_DownloadPath" MaxLines="2147483646" Height="20" IsReadOnly="True" Background="WhiteSmoke"/> <Button Content="Select" Width="64" Name="cmd_DownloadPath" Height="20"/> </DockPanel> </GroupBox> <GroupBox Header="Download" Margin="413,10,-38,293" Width="177" Height="43"> <Button Name="cmd_Download" Content="Not Ready" Margin="4,0,4,0" Foreground="White" Background="Red" Width="157" Height="20"/> </GroupBox> <GroupBox Header="Select Config" Margin="10,58,297,0" Height="266" VerticalAlignment="Top"> <StackPanel> <CheckBox Name="chk_SelectAll" Content="Select All" Height="22" HorizontalAlignment="Left" VerticalAlignment="Top" FontWeight="Bold" Foreground="#FF776FCE" /> <CheckBox Name="chk_Apps" Content="Apps" Height="17" HorizontalAlignment="Left" VerticalAlignment="Top"/> <CheckBox Name="chk_AppAssignment" Content="App Assignments" Height="17" HorizontalAlignment="Left" VerticalAlignment="Top"/> <CheckBox Name="chk_Deployment" Content="Deployment Profiles" Height="17" HorizontalAlignment="Left" VerticalAlignment="Top"/> <CheckBox Name="chk_SettingsCatalog" Content="Settings Catalog" Height="17" HorizontalAlignment="Left" VerticalAlignment="Top"/> <CheckBox Name="chk_SettingsCatalogAssignment" Content="Settings Catalog Assignment" Height="17" HorizontalAlignment="Left" VerticalAlignment="Top"/> <CheckBox Name="chk_DeviceCompliancePolicies" Content="Device Compliance Policies" Height="17" HorizontalAlignment="Left" VerticalAlignment="Top"/> <CheckBox Name="chk_DeviceCompliancePolicyAssignment" Content="Device Compliance Policy Assignments" Height="17" HorizontalAlignment="Left" VerticalAlignment="Top" /> <CheckBox Name="chk_DeviceConfigurations" Content="Device Configurations" Height="17" HorizontalAlignment="Left" VerticalAlignment="Top" /> <CheckBox Name="chk_DeviceConfigurationAssignments" Content="Device Configuration Assignments" Height="17" HorizontalAlignment="Left" VerticalAlignment="Top" /> <CheckBox Name="chk_DeviceEnrollmentStatusPage" Content="Device Enrollment Status Page" Height="17" HorizontalAlignment="Left" VerticalAlignment="Top"/> <CheckBox Name="chk_DeviceManagementScripts" Content="Device Management Scripts" Height="17" HorizontalAlignment="Left" VerticalAlignment="Top" /> <CheckBox Name="chk_DeviceManagementScriptAssignments" Content="Device Management Script Assignments" Height="17" HorizontalAlignment="Left" VerticalAlignment="Top" /> <CheckBox Name="chk_EndpointSecurity" Content="Endpoint Security" Height="17" HorizontalAlignment="Left" VerticalAlignment="Top" /> </StackPanel> </GroupBox> <GroupBox Header="Status" Margin="260,58,-38,22" Width="330"> <TextBox Name="txt_Status" IsReadOnly="True" TextWrapping="NoWrap" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Background="#FF140F75" Foreground="White" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Visible" Width="318" Height="240"/> </GroupBox> </Grid> </TabItem> <TabItem Header="Compare" Name="Tab_Compare"> <Grid Background="LightGray" HorizontalAlignment="Left" VerticalAlignment="Top" Height="419" Width="1092"> <Grid.RowDefinitions> <RowDefinition Height="Auto"/> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto"/> </Grid.ColumnDefinitions> <GroupBox Header="Compare" Margin="10,106,776,-135"> <DockPanel HorizontalAlignment="Stretch"> <Button Content="Not Ready" Width="277" Name="cmd_Import" Foreground="White" Background="Red"/> </DockPanel> </GroupBox> <GroupBox Header="Excel-File 1" Margin="9,8,776,-37"> <DockPanel HorizontalAlignment="Stretch"> <TextBox TextWrapping="NoWrap" Text="" Width="214" Name="txt_ExcelImport1" IsReadOnly="True" Background="WhiteSmoke" Height="20"/> <Button Content="Select" Width="63" Name="cmd_ExcelImport1"/> </DockPanel> </GroupBox> <GroupBox Header="Excel-File 2" Margin="10,56,776,-85"> <DockPanel HorizontalAlignment="Stretch"> <TextBox TextWrapping="NoWrap" Text="" Width="214" Name="txt_ExcelImport2" IsReadOnly="True" Background="WhiteSmoke" Height="20"/> <Button Content="Select" Width="63" Name="cmd_ExcelImport2"/> </DockPanel> </GroupBox> <GroupBox Header="Available Configs to compare (Doubleclick to open)" Margin="10,154,0,-397" HorizontalAlignment="Left" Width="293"> <ListBox x:Name="LB_AvaConfigs" ScrollViewer.VerticalScrollBarVisibility="Auto" Height="229" ScrollViewer.CanContentScroll="True" Width="277" HorizontalAlignment="Center" /> </GroupBox> <GroupBox Header="Result" Margin="308,8,0,-396" HorizontalAlignment="Left" Width="774"> <ListView x:Name="LV_Result" Height="377" HorizontalAlignment="Left" Width="764"> <ListView.View> <GridView> <GridView.ColumnHeaderContainerStyle> <Style TargetType="{x:Type GridViewColumnHeader}"> <Setter Property="HorizontalContentAlignment" Value="Center" /> </Style> </GridView.ColumnHeaderContainerStyle> <GridViewColumn Header="Categorie" Width="100" DisplayMemberBinding="{Binding Categorie}" TextBlock.TextAlignment="Center"/> <GridViewColumn Header="Name" Width="150" DisplayMemberBinding="{Binding Name}" TextBlock.TextAlignment="Center"/> <GridViewColumn Header="Property" Width="100" DisplayMemberBinding="{Binding Property}" TextBlock.TextAlignment="Center"/> <GridViewColumn Header="OldValue" Width="200" DisplayMemberBinding="{Binding OldValue}" TextBlock.TextAlignment="Center"/> <GridViewColumn Header="NewValue" Width="200" DisplayMemberBinding="{Binding NewValue}" TextBlock.TextAlignment="Center"/> </GridView> </ListView.View> </ListView> </GroupBox> </Grid> </TabItem> <TabItem Header="Search" Name="Tab_Search"> <Grid Background="LightGray" HorizontalAlignment="Left" VerticalAlignment="Top" Height="403" Width="1036"> <Grid.RowDefinitions> <RowDefinition Height="Auto"/> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto"/> </Grid.ColumnDefinitions> <GroupBox Header="Excel-File" Margin="10,10,0,305" HorizontalAlignment="Left" Width="251" Height="45"> <DockPanel HorizontalAlignment="Stretch"> <TextBox TextWrapping="NoWrap" Text="" Width="168" Name="txt_ExcelImport" IsReadOnly="True" Background="WhiteSmoke"/> <Button Content="Select" Width="63" Name="cmd_ExcelImport"/> </DockPanel> </GroupBox> <GroupBox Header="Filter" Margin="10,0,0,166" Height="134" VerticalAlignment="Bottom" HorizontalAlignment="Left" Width="251"> <DockPanel HorizontalAlignment="Stretch"> <ListBox Name="LB_Filter" Background="WhiteSmoke" Height="93" Width="235" DockPanel.Dock="Top" HorizontalAlignment="Left"/> <TextBox TextWrapping="NoWrap" Text="" Name="txt_AddFilter" DockPanel.Dock="Top" HorizontalAlignment="Left" Width="235"/> </DockPanel> </GroupBox> <GroupBox Header="Search" Margin="10,199,0,118" HorizontalAlignment="Left" Width="246" Height="43"> <DockPanel HorizontalAlignment="Stretch"> <Button Content="Not Ready" Width="234" Name="cmd_Search" Foreground="White" Background="Red"/> </DockPanel> </GroupBox> <GroupBox Header="Founded Categories (Doubleclick to open)" Margin="10,247,0,-33" Height="146" Width="251" HorizontalAlignment="Left"> <ListBox Name="LB_AvaResults" ScrollViewer.VerticalScrollBarVisibility="Auto" ScrollViewer.CanContentScroll="True" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" /> </GroupBox> <GroupBox Header="Result" Margin="266,10,0,-33" Width="760" HorizontalAlignment="Left" Height="383"> <ListView Name="LV_Search_Result" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" ScrollViewer.VerticalScrollBarVisibility="Visible" ScrollViewer.HorizontalScrollBarVisibility="Visible"> <ListView.View> <GridView> <GridView.ColumnHeaderContainerStyle> <Style TargetType="{x:Type GridViewColumnHeader}"> <Setter Property="HorizontalContentAlignment" Value="Center" /> </Style> </GridView.ColumnHeaderContainerStyle> </GridView> </ListView.View> </ListView> </GroupBox> </Grid> </TabItem> </TabControl> </TabItem> <TabItem Header="Apps" Name="Tab_Apps"> <TabControl VerticalAlignment="Stretch" HorizontalAlignment="Stretch"> <TabItem Header="Package" Name="Tab_Apps_Packaging"> <Grid Background="LightGray" HorizontalAlignment="Left" VerticalAlignment="Top" Height="150" Width="693"> <Grid.RowDefinitions> <RowDefinition Height="Auto"/> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto"/> </Grid.ColumnDefinitions> <GroupBox Header="Setupfiles-Path" Margin="10,10,0,383" Width="301" Height="44" HorizontalAlignment="Left"> <DockPanel HorizontalAlignment="Stretch"> <TextBox TextWrapping="NoWrap" Text="" Width="219" Name="txt_Apps_SetupfilePath" MaxLines="2147483646" Height="20" IsReadOnly="True" Background="WhiteSmoke"/> <Button Content="Select" Width="64" Name="cmd_Apps_SetupfilePath" Height="20"/> </DockPanel> </GroupBox> <GroupBox Header="Package-Path" Margin="10,59,0,334" Width="301" Height="44" HorizontalAlignment="Left"> <DockPanel HorizontalAlignment="Stretch"> <TextBox TextWrapping="NoWrap" Text="" Width="219" Name="txt_Apps_PackagePath" MaxLines="2147483646" Height="20" IsReadOnly="True" Background="WhiteSmoke"/> <Button Content="Select" Width="64" Name="cmd_Apps_PackagePath" Height="20"/> </DockPanel> </GroupBox> <GroupBox Header="Package" Margin="10,103,0,291" Height="43" HorizontalAlignment="Left" Width="301"> <Button Name="cmd_Apps_Packaging" Content="Not Ready" Margin="0,0,-2,0" Foreground="White" Background="Red" Height="20"/> </GroupBox> <GroupBox Header="Status" Margin="316,10,0,0" Width="367" Height="136" VerticalAlignment="Top" HorizontalAlignment="Left"> <TextBox Name="txt_Apps_Package_Status" IsReadOnly="True" TextWrapping="NoWrap" Background="#FF140F75" Foreground="White" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Visible" Height="113" Margin="0,0,-2,0"/> </GroupBox> </Grid> </TabItem> <TabItem Header="Deploy" Name="Tab_Apps_Deploying" IsEnabled="False"> </TabItem> <TabItem Header="Download" Name="Tab_Apps_Download" IsEnabled="False"> </TabItem> </TabControl> </TabItem> </TabControl> </Window> "@ -replace 'mc:Ignorable="d"', '' -replace "x:N", 'N' -replace '^<Win.*', '<Window' #XAML laden [void][System.Reflection.Assembly]::LoadWithPartialName('presentationframework') try { $Global:Form = [Windows.Markup.XamlReader]::Load( (New-Object System.Xml.XmlNodeReader $XAML) ) } catch { Write-Host "Windows.Markup.XamlReader konnte nicht geladen werden. M�gliche Ursache: ung�ltige Syntax oder fehlendes .net" } Add-Type -AssemblyName PresentationFramework, System.Drawing, System.Windows.Forms, WindowsFormsIntegration #ICON $base64 = "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" $bitmap = New-Object System.Windows.Media.Imaging.BitmapImage $bitmap.BeginInit() $bitmap.StreamSource = [System.IO.MemoryStream][System.Convert]::FromBase64String($base64) $bitmap.EndInit() $bitmap.Freeze() $Form.Icon = $bitmap $Form.TaskbarItemInfo.Overlay = $bitmap $Form.TaskbarItemInfo.Description = $Form.Title #Hide PowerShell Console Add-Type -Name Window -Namespace Console -MemberDefinition ' [DllImport("Kernel32.dll")] public static extern IntPtr GetConsoleWindow(); [DllImport("user32.dll")] public static extern bool ShowWindow(IntPtr hWnd, Int32 nCmdShow); ' $consolePtr = [Console.Window]::GetConsoleWindow() [Console.Window]::ShowWindow($consolePtr, 0) | Out-Null #Add_Control $XAML.SelectNodes("//*[@*[contains(translate(name(.),'n','N'),'Name')]]") | ForEach { New-Variable -Name $_.Name -Value $Form.FindName($_.Name) -Force -PassThru | Out-Null } #endregion #region - FUNCTION 'FOR ALL' function func_ControlHandle($tool, $switch) { if ($tool -eq 'Download') { Foreach ($chkcontrol in Get-Variable -Name 'chk_*') { If ($chkcontrol) { $chkcontrol.value.IsEnabled = $switch } } If ($switch -eq $false) { $cmd_Download.Background = 'orange' $cmd_Download.Content = 'Cancel' } else {func_Download_CheckAll} $Tab_Apps.isEnabled = $switch $txt_DownloadPath.IsEnabled = $switch $cmd_DownloadPath.IsEnabled = $switch $Tab_Compare.IsEnabled = $switch $Tab_Search.isEnabled = $switch } elseif ($tool -eq 'Compare') { $Tab_Apps.isEnabled = $switch $cmd_ExcelImport1.IsEnabled = $switch $cmd_ExcelImport2.IsEnabled = $switch $Tab_Download.IsEnabled = $switch $Tab_Compare.IsEnabled = $switch $Tab_Search.isEnabled = $switch $txt_ExcelImport1.IsEnabled = $switch $txt_ExcelImport2.IsEnabled = $switch } elseif ($tool -eq 'Search') { $Tab_Apps.isEnabled = $switch $cmd_ExcelImport.IsEnabled = $switch $txt_ExcelImport.IsEnabled = $switch $Tab_Download.IsEnabled = $switch $Tab_Compare.IsEnabled = $switch $Tab_Search.isEnabled = $switch $txt_AddFilter.isEnabled = $switch $LB_Filter.IsEnabled = $switch } elseif ($tool -eq 'Package') { If ($switch -eq $false) { $cmd_Apps_Packaging.Background = 'orange' $cmd_Apps_Packaging.Content = 'Cancel' } else {func_Apps_Readycheck_Package} $Tab_Reports.isEnabled = $switch $txt_Apps_SetupfilePath.isEnabled = $switch $txt_Apps_PackagePath.isEnabled = $switch $cmd_Apps_SetupfilePath.isEnabled = $switch $cmd_Apps_PackagePath.isEnabled = $switch } [System.Windows.Forms.Application]::DoEvents() } function func_Timestemp($Fullpath) { $Timestemp = Get-date -Format "dd.MM.yyyy-HH.mm" $SystemIO = ([System.IO.FileInfo]$Fullpath).Name $Splitter = $SystemIO.Split('.') [string]$Fullname = $null $Fullnamevalue = 1 Foreach ($entry in $Splitter) { If ($Fullnamevalue -eq $Splitter.Count) { $Fullname += $entry } elseif ($Fullnamevalue -eq 1) { $Fullname += -join ($entry, '-' , $Timestemp, '.') } else { $Fullname += -join ($entry, '.') } $Fullnamevalue += 1 } return $Fullname } #endregion #region - FUNCTIONS 'DOWNLOAD' function func_Download_Downloadpath { $txt_DownloadPath.Text = $null $WinFiles = $null $FileBrowser = New-Object System.Windows.Forms.SaveFileDialog $FileBrowser.Reset() $FileBrowser.Filter = "Excel files (*.xlsx)|*.xlsx" $FileBrowser.ShowDialog() | Out-Null $WinFiles = $FileBrowser.FileName If (!($WinFiles -eq "")) { $txt_DownloadPath.Text = $WinFiles } else { $txt_DownloadPath.Text = $null } func_Download_Readycheck_Download } function func_Download_Status_Changed() { $txt_Status.Focus() $txt_Status.ScrollToEnd() } function func_Download_CheckAll { Foreach ($chkcontrol in Get-Variable -Name 'chk_*') { If ($chkcontrol) { $($chkcontrol.value).isChecked = $chk_SelectAll.IsChecked } } func_Download_Readycheck_Download } function func_Download_Readycheck_Download { Foreach ($chkcontrol in Get-Variable | Where-Object { $_.Name -like 'chk_*' -and $_.Name -ne 'chk_SelectAll' }) { If ($chkcontrol) { If (($chkcontrol.Value).IsChecked -eq $true) { $check_chkbox = $true break } } $check_chkbox = $false } If ($check_chkbox -eq $true -and $txt_DownloadPath.Text -ne '' -and $txt_DownloadPath.Text -like '*.xlsx') { $cmd_Download.Background = 'green' $cmd_Download.Content = 'Ready' } else { $cmd_Download.Background = 'red' $cmd_Download.Content = 'Not Ready' } } function func_Download { If ($cmd_Download.Content -eq 'Ready') { #Disable Controls func_ControlHandle -tool 'Download' -switch $false $cmd_Download.IsEnabled = $false $Folder = 'C:\tmp' $tempFolder = -join ('tmp_', $([System.IO.Path]::GetRandomFileName().replace('.', ''))) $Filename = func_Timestemp -Fullpath $txt_DownloadPath.Text $txt_Status.AppendText("Create temp-Folder $("$Folder\$tempFolder")") $txt_Status.AppendText([Environment]::NewLine) $PID_Path = -join ($Folder,'\' , $tempFolder) $Joblist = @{} Foreach ($chkcontrol in Get-Variable -Name 'chk_*') { If ($chkcontrol) { $Joblist.add($chkcontrol.Name, $chkcontrol.value.isChecked) } } $Job = Start-Job -Name "work" -ScriptBlock ${Function:func_DownloadPackage} -ArgumentList $Folder, $tempFolder, $Filename, $Joblist $Global:JobID = $null Do { [System.Windows.Forms.Application]::DoEvents() $ReceiveStatus = $(Receive-Job $Job) $txt_Status.AppendText($ReceiveStatus) if ($Global:JobID -eq $null) { if (Test-Path -Path "$Folder\$tempFolder\PID.txt") { $Global:Jobid = Get-Content -Path "$Folder\$tempFolder\PID.txt" } } else{ Remove-Item -Path "$Folder\$tempFolder\PID.txt" -Confirm:$false -Force -ErrorAction SilentlyContinue | Out-Null $cmd_Download.IsEnabled = $true } } While ($Job.State -eq 'Running') Remove-Job * -Force func_ControlHandle -tool 'Download' -switch $true } Elseif ($cmd_Download.Content -eq 'Cancel') { Stop-Process -Id $Global:Jobid -Confirm:$false -Force | Out-Null Remove-Item -Path "$Folder\$tempFolder" -Confirm:$false -Recurse -Force -ErrorAction SilentlyContinue | Out-Null Remove-Item -Path "$Folder\$tempFolder" -Confirm:$false -Force -ErrorAction SilentlyContinue | Out-Null $txt_Status.AppendText('Aborted') $txt_Status.AppendText([Environment]::NewLine) } } #endregion #region - FUNCTIONS 'COMPARE' function func_COMPARE_Readycheck { If ($txt_ExcelImport1.Text -like '*.xlsx*' -and $txt_ExcelImport2.Text -like '*.xlsx*') { $cmd_Import.Background = 'green' $cmd_Import.Content = 'Ready' } else { $cmd_Import.Background = 'red' $cmd_Import.Content = 'Not Ready' } } function func_Compare_ExcelImport ($mode) { If ($mode -eq 'Excel1') { $txt_ExcelImport1.Text = $null $Filepath = $null $WinFiles = $null $FileBrowser = New-Object System.Windows.Forms.OpenFileDialog $FileBrowser.Reset() $FileBrowser.Filter = "Excel files (*.xlsx)|*.xlsx" $FileBrowser.ShowDialog() | Out-Null $WinFiles = $FileBrowser.FileName If (!($WinFiles -eq "")) { $txt_ExcelImport1.Text = $WinFiles } else { $txt_ExcelImport1.Text = $null } } ElseIf ($mode -eq 'Excel2') { $txt_ExcelImport2.Text = $null $Filepath = $null $WinFiles = $null $FileBrowser = New-Object System.Windows.Forms.OpenFileDialog $FileBrowser.Reset() $FileBrowser.Filter = "Excel files (*.xlsx)|*.xlsx" $FileBrowser.ShowDialog() | Out-Null $WinFiles = $FileBrowser.FileName If (!($WinFiles -eq "")) { $txt_ExcelImport2.Text = $WinFiles } else { $txt_ExcelImport2.Text = $null } } func_COMPARE_Readycheck } function func_Compare_Import { If ($cmd_Import.Content -eq 'Ready') { $Global:Jobid = $null $Global:CompareResults = $null $cmd_Import.Content = 'Cancel' $cmd_Import.Background = 'Orange' $cmd_Import.IsEnabled = $false func_ControlHandle -tool 'Compare' -switch $false $LB_AvaConfigs.Items.Clear() $LV_Result.Items.Clear() $tempFolder = -join ('tmp_', $([System.IO.Path]::GetRandomFileName().replace('.', ''))) $PID_Path = -join ('C:\tmp\', $tempFolder) [System.Windows.Forms.Application]::DoEvents() $Global:Jobid = $null $Job = Start-Job -Name "work" -ScriptBlock ${Function:func_ComparePackage} -ArgumentList $PID_Path, $txt_ExcelImport1.Text, $txt_ExcelImport2.Text Do { [System.Windows.Forms.Application]::DoEvents() If ($Global:Jobid -eq $null) { if (Test-Path -Path "$PID_Path\PID.txt") {$Global:Jobid = Get-Content -Path "$PID_Path\PID.txt"} } else { $cmd_Import.IsEnabled = $true Remove-Item -Path "$PID_Path\PID.txt" -Confirm:$false -Force -ErrorAction SilentlyContinue | Out-Null } } While ($Job.State -eq 'Running') $Global:CompareResults += Receive-Job $Job Remove-Job * -Force Foreach ($Result in $Global:CompareResults) { If (!($LB_AvaConfigs.Items.Contains($Result.Categorie))) { $LB_AvaConfigs.Items.Add($Result.Categorie) } [System.Windows.Forms.Application]::DoEvents() } Remove-Item -Path "$PID_Path" -Confirm:$false -Recurse -Force -ErrorAction SilentlyContinue | Out-Null Remove-Item -Path "$PID_Path" -Confirm:$false -Force -ErrorAction SilentlyContinue | Out-Null func_ControlHandle -tool 'Compare' -switch $true func_COMPARE_Readycheck } Elseif ($cmd_Import.Content -eq 'Cancel' -and $Global:Jobid) { Stop-Process -Id $Global:Jobid -Confirm:$false -Force | Out-Null Remove-Item -Path "C:\tmp\$tempFolder" -Confirm:$false -Recurse -Force -ErrorAction SilentlyContinue | Out-Null Remove-Item -Path "C:\tmp\$tempFolder" -Confirm:$false -Force -ErrorAction SilentlyContinue | Out-Null func_ControlHandle -tool 'Compare' -switch $true func_COMPARE_Readycheck } } function func_Compare_Select { $LV_Result.Items.Clear() Foreach ($entry in $Global:CompareResults) { If ($entry.Categorie -eq $LB_AvaConfigs.SelectedItem) { $LV_Result.Items.Add($entry) } } } function func_Compare_Massopen { $LV_Result.Items | Out-GridView -Title 'Cleoni' } #endregion #region - FUNCTIONS 'SEARCH' function func_Search_ExcelImport { $txt_ExcelImport.Text = $null $Filepath = $null $WinFiles = $null $FileBrowser = New-Object System.Windows.Forms.OpenFileDialog $FileBrowser.Reset() $FileBrowser.Filter = "Excel files (*.xlsx)|*.xlsx" $FileBrowser.ShowDialog() | Out-Null $WinFiles = $FileBrowser.FileName If (!($WinFiles -eq "")) { $txt_ExcelImport.Text = $WinFiles } else { $txt_ExcelImport.Text = $null } func_SEARCH_Readycheck } function func_Search_FilterHandle ($mode) { If ($mode -eq 'add') { If (!($LB_Filter.Items.Contains($txt_AddFilter.Text) ) -and $txt_AddFilter.Text.Length -ge 1) { $LB_Filter.AddText($txt_AddFilter.Text) $txt_AddFilter.Text = '' } } elseif ($mode -eq 'remove') { If (!($LB_Filter.SelectedItems.Count -eq 0)) { $LB_Filter.Items.Remove($LB_Filter.SelectedItem) } } func_SEARCH_Readycheck } function func_SEARCH_Readycheck { If ($txt_ExcelImport.Text -like '*.xlsx*' -and $LB_Filter.Items.Count -ge 1) { $cmd_Search.Background = 'green' $cmd_Search.Content = 'Ready' } else { $cmd_Search.Background = 'red' $cmd_Search.Content = 'Not Ready' } } function func_SEARCH { If ($cmd_Search.Content -eq 'Ready') { $Global:Jobid = $null $Global:SearchResults = $null $cmd_Search.Content = 'Cancel' $cmd_Search.Background = 'Orange' $cmd_Search.IsEnabled = $false func_ControlHandle -tool 'Search' -switch $false $LB_AvaResults.Items.Clear() $LV_Search_Result.Items.Clear() $tempFolder = -join ('tmp_', $([System.IO.Path]::GetRandomFileName().replace('.', ''))) $PID_Path = -join ('C:\tmp\', $tempFolder) [System.Windows.Forms.Application]::DoEvents() $Global:Jobid = $null $Job = Start-Job -Name "work" -ScriptBlock ${Function:func_Searche} -ArgumentList $PID_Path, $txt_ExcelImport.Text, $LB_Filter.Items Do { [System.Windows.Forms.Application]::DoEvents() If ($Global:Jobid -eq $null) { if (Test-Path -Path "$PID_Path\PID.txt") { $Global:Jobid = Get-Content -Path "$PID_Path\PID.txt" } } else { $cmd_Search.IsEnabled = $true Remove-Item -Path "$Folder\$tempFolder\PID.txt" -Confirm:$false -Force -ErrorAction SilentlyContinue | Out-Null } } While ($Job.State -eq 'Running') $Global:SearchResults += Receive-Job $Job Remove-Job * -Force Foreach ($Result in $Global:SearchResults) { If (!($LB_AvaResults.Items.Contains($Result.Topic))) { $LB_AvaResults.Items.Add($Result.Topic) } [System.Windows.Forms.Application]::DoEvents() } Remove-Item -Path "$PID_Path" -Confirm:$false -Recurse -Force -ErrorAction SilentlyContinue | Out-Null Remove-Item -Path "$PID_Path" -Confirm:$false -Force -ErrorAction SilentlyContinue | Out-Null func_ControlHandle -tool 'Search' -switch $true func_SEARCH_Readycheck } Elseif ($cmd_Search.Content -eq 'Cancel' -and $Global:Jobid) { Stop-Process -Id $Global:Jobid -Confirm:$false -Force | Out-Null Remove-Item -Path "C:\tmp\$tempFolder" -Confirm:$false -Recurse -Force -ErrorAction SilentlyContinue | Out-Null Remove-Item -Path "C:\tmp\$tempFolder" -Confirm:$false -Force -ErrorAction SilentlyContinue | Out-Null func_ControlHandle -tool 'Search' -switch $true func_SEARCH_Readycheck } } function func_Search_Massopen { $LV_Search_Result.Items | Out-GridView -Title 'Cleoni' } function func_Search_Select { $LV_Search_Result.Items.Clear() $LV_Search_Result.view.Columns.Clear() $CreateColumns = $true Foreach ($entry in $Global:SearchResults) { If ($entry.Topic -eq $LB_AvaResults.SelectedItem) { If ($CreateColumns -eq $True) { $members = $entry.value.psobject.properties | select -ExpandProperty Name Foreach($member in $members) { $GridviewCol = [System.Windows.Controls.GridViewColumn]::new() $GridviewCol.DisplayMemberBinding = [System.Windows.Data.Binding]::new($member) $GridviewCol.Header = $member $GridviewCol.Width = '100' $LV_Search_Result.View.Columns.Add($GridviewCol) } $CreateColumns = $false } $LV_Search_Result.Items.Add($entry.Value) } } } function func_Search_Filter_Watermarked($mode) { If ($mode -eq 'focus') { If ($txt_AddFilter.Text){ $txt_AddFilter.Text = '' $txt_AddFilter.Foreground = 'Black' $txt_AddFilter.FontStyle = 'Normal' } } elseIf ($mode -eq 'lost') { $txt_AddFilter.Text = 'Enter here' $txt_AddFilter.Foreground = 'Gray' $txt_AddFilter.FontStyle = 'Italic' } } #endregion #region - FUNCTIONS 'PACKAGE' function func_Apps_Package_Status_Changed() { $txt_Apps_Package_Status.Focus() $txt_Apps_Package_Status.ScrollToEnd() } function func_Apps_Readycheck_Package { If ($txt_Apps_SetupfilePath.Text -ne '' -and $txt_Apps_PackagePath.Text -like '*.intunewin') { $SetupfilePath = ([System.IO.FileInfo]$txt_Apps_SetupfilePath.Text).DirectoryName $PackagePath = ([System.IO.FileInfo]$txt_Apps_PackagePath.Text).DirectoryName If (!($SetupfilePath -eq $PackagePath)) { $cmd_Apps_Packaging.Background = 'green' $cmd_Apps_Packaging.Content = 'Ready' } else { $cmd_Apps_Packaging.Background = 'red' $cmd_Apps_Packaging.Content = 'Not Ready - Directories are equal' } } else { $cmd_Apps_Packaging.Background = 'red' $cmd_Apps_Packaging.Content = 'Not Ready' } } function func_Apps_SetupfilePath { $txt_Apps_SetupfilePath.Text = $null $SouPath = $null $OpenBrowser = New-Object System.Windows.Forms.OpenFileDialog $OpenBrowser.Reset() $OpenBrowser.ShowDialog() | Out-Null If ($OpenBrowser.FileName) { [System.IO.FileInfo]$SouPath = $OpenBrowser.FileName $txt_Apps_SetupfilePath.Text = $SouPath } else { $txt_Apps_SetupfilePath.Text = $null } func_Apps_Readycheck_Package } function func_Apps_PackagePath { $txt_Apps_PackagePath.Text = $null $DesPath = $null $SaveBrowser = New-Object System.Windows.Forms.SaveFileDialog $SaveBrowser.Reset() $SaveBrowser.Filter = "Win32App file (*.intunewin)|*.intunewin" $SaveBrowser.ShowDialog() | Out-Null If ($SaveBrowser.FileName) { [System.IO.FileInfo]$DesPath = $SaveBrowser.FileName $txt_Apps_PackagePath.Text = $DesPath } else { $txt_Apps_PackagePath.Text = $null } func_Apps_Readycheck_Package } function func_Apps_Package { If ($cmd_Apps_Packaging.Content -eq 'Ready') { #Disable Controls func_ControlHandle -tool 'Package' -switch $false $cmd_Apps_Packaging.IsEnabled = $false $Folder = 'C:\tmp' $tempFolder = -join ('tmp_', $([System.IO.Path]::GetRandomFileName().replace('.', ''))) $txt_Apps_Package_Status.AppendText("Create temp-Folder $("$Folder\$tempFolder")") $txt_Apps_Package_Status.AppendText([Environment]::NewLine) $PID_Path = -join ($Folder,'\' , $tempFolder) $Joblist = @{} $Joblist = '' | Select Setupfile, OutputFolder,Intune32Tool $Joblist.SetupFile = $txt_Apps_SetupfilePath.Text $Joblist.OutputFolder = $txt_Apps_PackagePath.Text $Joblist.Intune32Tool = "$PSScriptRoot\IntuneWinAppUtil.exe" [System.Windows.Forms.Application]::DoEvents() $Job = Start-Job -Name "work" -ScriptBlock ${Function:func_Package} -ArgumentList $Folder, $tempFolder, $Joblist $Global:JobID = $null Do{ [System.Windows.Forms.Application]::DoEvents() $ReceiveStatus = $(Receive-Job $Job) $txt_Apps_Package_Status.AppendText($ReceiveStatus) if ($Global:JobID -eq $null) { if (Test-Path -Path "$Folder\$tempFolder\PID.txt") { $Global:Jobid = Get-Content -Path "$Folder\$tempFolder\PID.txt" } } else{ Remove-Item -Path "$Folder\$tempFolder\PID.txt" -Confirm:$false -Force -ErrorAction SilentlyContinue | Out-Null $cmd_Apps_Packaging.IsEnabled = $true } }While ($Job.State -eq 'Running') Remove-Job * -Force func_ControlHandle -tool 'Package' -switch $true } Elseif ($cmd_Apps_Packaging.Content -eq 'Cancel') { Stop-Process -Id $Global:Jobid -Confirm:$false -Force | Out-Null Stop-Process -Name 'IntuneWinAppUtil' -Confirm:$false -Force | Out-Null Remove-Item -Path "$Folder\$tempFolder" -Confirm:$false -Recurse -Force -ErrorAction SilentlyContinue | Out-Null Remove-Item -Path "$Folder\$tempFolder" -Confirm:$false -Force -ErrorAction SilentlyContinue | Out-Null $txt_Apps_Package_Status.AppendText('Aborted') $txt_Apps_Package_Status.AppendText([Environment]::NewLine) } func_Apps_Readycheck_Package } #endregion #region - AddControls 'DOWNLOAD' $chk_SelectAll.Add_Click( { func_Download_CheckAll }) $chk_Apps.Add_Click( { func_Download_Readycheck_Download }) $chk_AppAssignment.Add_Click( { func_Download_Readycheck_Download }) $chk_Deployment.Add_Click( { func_Download_Readycheck_Download }) $chk_SettingsCatalog.Add_Click( { func_Download_Readycheck_Download }) $chk_SettingsCatalogAssignment.Add_Click( { func_Download_Readycheck_Download }) $chk_DeviceCompliancePolicies.Add_Click( { func_Download_Readycheck_Download }) $chk_DeviceCompliancePolicyAssignment.Add_Click( { func_Download_Readycheck_Download }) $chk_DeviceConfigurations.Add_Click( { func_Download_Readycheck_Download }) $chk_DeviceConfigurationAssignments.Add_Click( { func_Download_Readycheck_Download }) $chk_DeviceEnrollmentStatusPage.Add_Click( { func_Download_Readycheck_Download }) $chk_DeviceManagementScripts.Add_Click( { func_Download_Readycheck_Download }) $chk_DeviceManagementScriptAssignments.Add_Click( { func_Download_Readycheck_Download }) $chk_EndpointSecurity.Add_Click( { func_Download_Readycheck_Download }) $txt_Status.Add_TextChanged( { func_Download_Status_Changed }) $txt_DownloadPath.Add_TextChanged( { func_Download_Readycheck_Download }) $cmd_DownloadPath.Add_Click( { func_Download_Downloadpath }) $cmd_Download.Add_Click( { func_Download }) #endregion #region - AddControls 'COMPARE' $cmd_ExcelImport1.Add_Click( { func_Compare_ExcelImport -mode 'Excel1' }) $cmd_ExcelImport2.Add_Click( { func_Compare_ExcelImport -mode 'Excel2' }) $cmd_Import.Add_Click( { func_Compare_Import }) $LB_AvaConfigs.Add_SelectionChanged({ func_Compare_Select }) $LB_AvaConfigs.Add_MouseDoubleClick({ func_Compare_Massopen }) #endregion #region - AddControls 'SEARCH' $cmd_ExcelImport.Add_Click( { func_Search_ExcelImport }) $txt_AddFilter.Add_KeyDown({ if($_.Key -eq "Enter") { func_Search_FilterHandle -mode 'add' } }) $txt_AddFilter.Add_GotFocus({ func_Search_Filter_Watermarked -mode 'focus' }) $txt_AddFilter.Add_LostFocus({ func_Search_Filter_Watermarked -mode 'lost' }) func_Search_Filter_Watermarked -mode 'lost' $LB_Filter.Add_KeyDown({ if($_.Key -eq "Delete") { func_Search_FilterHandle -mode 'remove' } }) $LB_Filter.Add_MouseDoubleClick({ func_Search_FilterHandle -mode 'remove' }) $cmd_Search.Add_Click( { func_SEARCH }) $LB_AvaResults.Add_SelectionChanged({ func_Search_Select }) $LB_AvaResults.Add_MouseDoubleClick({ func_Search_Massopen }) #endregion #region - AddControls 'PACKAGE' $txt_Apps_SetupfilePath.Add_TextChanged( { func_Apps_Readycheck_Package }) $txt_Apps_PackagePath.Add_TextChanged( { func_Apps_Readycheck_Package }) $txt_Apps_Package_Status.Add_TextChanged( { func_Apps_Package_Status_Changed }) $cmd_Apps_SetupfilePath.Add_Click( { func_Apps_SetupfilePath }) $cmd_Apps_PackagePath.Add_Click( { func_Apps_PackagePath }) $cmd_Apps_Packaging.Add_Click( { func_Apps_Package }) #endregion $Form.Add_Closing({ param($sender, $e) If (Test-Path -Path "$Folder\$tempFolder") { If (Test-Path -Path "$Folder\$tempFolder\PID.txt") { $Global:Jobid = Get-Content -Path "$Folder\$tempFolder\PID.txt" } If ($Global:Jobid) { Stop-Process -Id $Global:Jobid -Confirm:$false -Force | Out-Null } } }) $Form.ShowDialog() | out-null Stop-Process -Id $PID -Confirm:$false -Force | Out-Null } #Check PowerShell Version $Powershell_App = (Get-Process -Id $PID).ProcessName If (!($Powershell_App -eq 'powershell')) { Start-Process powershell.exe -ArgumentList ('-noprofile -file "{0}" -elevated' -f ($myinvocation.MyCommand.Definition)) exit $LASTEXITCODE } marli-cleoni |