mirror of
https://github.com/Micke-K/IntuneManagement.git
synced 2026-11-27 09:22:26 +01:00
Development snapshot 2026-10-25 (4.0.0-beta1 + fixes)
This commit is contained in:
@@ -352,6 +352,12 @@ function Initialize-UI {
|
||||
Initialize-AvaloniaRuntime
|
||||
}
|
||||
|
||||
# The menu item names what a click will do, so it follows the console state.
|
||||
function Update-ConsoleWindowMenu {
|
||||
$header = if (Get-ConsoleWindowVisible) { '_Hide console' } else { '_Show console' }
|
||||
$script:UIProvider.SetXamlProperty($script:Window, 'mnuToggleConsole', 'Header', $header)
|
||||
}
|
||||
|
||||
function Show-MainWindow {
|
||||
param($View)
|
||||
|
||||
@@ -470,6 +476,19 @@ public static class IMMaximizeMetrics
|
||||
try { $ui.ShowAboutDialog() } catch { Write-LogError "Show-AboutDialog failed" $_.Exception }
|
||||
}))
|
||||
|
||||
# File > Hide console / Show console. Windows, classic console host only
|
||||
# (Internal/ConsoleWindow.ps1); on macOS and Linux, and under Windows
|
||||
# Terminal, there is nothing it could do, so the item is not shown.
|
||||
if (Test-ConsoleWindowSupported) {
|
||||
$ui.AddXamlEvent($script:Window, 'mnuToggleConsole', 'Add_Click', ({
|
||||
try { [void](Switch-ConsoleWindow); Update-ConsoleWindowMenu } catch { Write-LogError "Toggle console failed" $_.Exception }
|
||||
}))
|
||||
Update-ConsoleWindowMenu
|
||||
}
|
||||
else {
|
||||
$ui.SetXamlProperty($script:Window, 'mnuToggleConsole', 'IsVisible', $false)
|
||||
}
|
||||
|
||||
$ui.AddXamlEvent($script:Window, 'mnuSettings', 'Add_Click', ({
|
||||
try { Show-SettingsForm } catch { Write-LogError "Show-SettingsForm failed" $_.Exception }
|
||||
}))
|
||||
@@ -513,6 +532,18 @@ public static class IMMaximizeMetrics
|
||||
# Stacks on top of the welcome modal on a first run off Windows, so the
|
||||
# experimental warning is the first thing read and the first dismissed.
|
||||
try { Show-ExperimentalPlatformNotice } catch { Write-LogError 'Show-ExperimentalPlatformNotice failed' $_.Exception }
|
||||
|
||||
# Setting HideConsoleWindow: hide the console once the window is up.
|
||||
if ((Get-SettingValue "HideConsoleWindow") -eq $true -and (Test-ConsoleWindowSupported)) {
|
||||
try { [void](Hide-ConsoleWindow); Update-ConsoleWindowMenu } catch { Write-LogError 'Hide-ConsoleWindow failed' $_.Exception }
|
||||
}
|
||||
}))
|
||||
|
||||
# Give the console back on exit: Start.cmd ends in `pause`, which would
|
||||
# otherwise wait for a key in a window nobody can see.
|
||||
$script:Window.add_Closed((ConvertTo-AvaloniaEventScriptBlock {
|
||||
param($S, $E)
|
||||
if ((Test-ConsoleWindowSupported) -and -not (Get-ConsoleWindowVisible)) { [void](Show-ConsoleWindow) }
|
||||
}))
|
||||
|
||||
# Tell Windows this process is the Intune Management app so the taskbar
|
||||
@@ -934,8 +965,13 @@ function Show-ReleaseNotes {
|
||||
|
||||
$remote = $null
|
||||
$header = $null
|
||||
$failure = $null
|
||||
try {
|
||||
$remote = Get-AppRemoteReleaseNotes
|
||||
# Read straight after the call: Get-AppUpdateInfo below clears the recorded
|
||||
# reason at its start, so asking later would report the version lookup's
|
||||
# failure instead of this one.
|
||||
if (-not $remote) { $failure = Get-AppUpdateLastError }
|
||||
$info = Get-AppUpdateInfo
|
||||
if ($info.IsOutdated) {
|
||||
$header = "A newer version is available on GitHub: $($info.RemoteVersion.ToString()) (installed: $($info.LocalVersion.ToString()))"
|
||||
@@ -947,6 +983,15 @@ function Show-ReleaseNotes {
|
||||
catch { Write-LogError 'Failed to get release notes from GitHub' $_.Exception }
|
||||
|
||||
$body = if ($remote -and $remote.Text) { $remote.Text } else { $localNotes }
|
||||
|
||||
# Falling back to the local copy silently makes a rate-limited check look like the
|
||||
# published notes simply match. Say which copy this is and why.
|
||||
if (-not ($remote -and $remote.Text)) {
|
||||
$note = if ($failure) { "Showing the local ReleaseNotes.md - could not read the published notes: $failure" }
|
||||
else { 'Showing the local ReleaseNotes.md - could not read the published notes.' }
|
||||
$header = if ($header) { $note + [Environment]::NewLine + $header } else { $note }
|
||||
}
|
||||
|
||||
$content = if ($header) {
|
||||
$header + [Environment]::NewLine + ('-' * 72) + [Environment]::NewLine + [Environment]::NewLine + $body
|
||||
} else {
|
||||
@@ -1422,6 +1467,8 @@ function Show-AboutDialog
|
||||
}
|
||||
|
||||
$ui.SetXamlProperty($dlgAbout, 'txtTitle', 'Text', 'Intune Management')
|
||||
# From the manifest (Internal/AppInfo.ps1), not the XAML - see the comment there.
|
||||
$ui.SetXamlProperty($dlgAbout, 'txtCopyright', 'Text', (Get-AppCopyright))
|
||||
if ($script:ActiveView) {
|
||||
$ui.SetXamlProperty($dlgAbout, 'txtViewTitle', 'Text', ("Current view: " + $script:ActiveView.Title))
|
||||
if ($script:ActiveView.Description) {
|
||||
|
||||
@@ -189,7 +189,18 @@ function Show-GraphBulkImportForm
|
||||
Write-Status ""
|
||||
|
||||
$unknownNote = Get-IntuneUnknownSelectorSummary $summary.UnknownSelectors
|
||||
if ($totalImported -eq 0) {
|
||||
$approvalNote = Get-MSGraphApprovalPendingSummary $summary.PendingApproval
|
||||
if ($approvalNote) {
|
||||
# Held writes are queued, not failed - "no objects were imported,
|
||||
# verify the folder" would send the user looking for a non-problem.
|
||||
$msg = $approvalNote
|
||||
if ($totalImported -gt 0) { $msg = ("Imported {0} object(s) from:`n{1}`n`n{2}" -f $totalImported, $importFolder, $msg) }
|
||||
if ($unknownNote) { $msg += "`n`n$unknownNote" }
|
||||
$ui.ShowMessageBox($msg, "Bulk Import", "OK", "Information") | Out-Null
|
||||
if ($totalImported -gt 0 -and $script:IntuneManagerSelectedObject) {
|
||||
Invoke-IntuneActivateObject $script:IntuneManagerSelectedObject | Out-Null
|
||||
}
|
||||
} elseif ($totalImported -eq 0) {
|
||||
$msg = "No objects were imported.`nVerify the import folder and exported files."
|
||||
if ($unknownNote) { $msg += "`n`n$unknownNote" }
|
||||
$ui.ShowMessageBox($msg, "Bulk Import", "OK", "Warning") | Out-Null
|
||||
|
||||
@@ -22,6 +22,34 @@
|
||||
# Normalize-IntuneImportPolicyName) live in Internal/IntuneManager.ps1 and
|
||||
# are shared with the WPF tree.
|
||||
|
||||
function Get-IntuneManagerImportExistingPolicies
|
||||
{
|
||||
# Candidates for the skip / update / replace match (#384). Two things hid
|
||||
# existing objects from it: pages the view had not loaded yet, and the filter
|
||||
# box - the grid shows the filtered subset of IntuneManagerAllRows. So: every
|
||||
# loaded row, plus whatever Get-IntuneImportCandidates (Internal/IntuneManager.ps1)
|
||||
# finds in Graph for these files. It never loads every page. Cached for the
|
||||
# dialog: the import type changing does not change what exists.
|
||||
param($ImportPolicies, [string]$ImportType, [bool]$SameTenant)
|
||||
|
||||
$rows = @()
|
||||
if ($script:IntuneManagerAllRows) { $rows = $script:IntuneManagerAllRows }
|
||||
elseif ($script:dgIntuneManagerObjects) { $rows = $script:dgIntuneManagerObjects.ItemsSource }
|
||||
$loaded = @($rows | ForEach-Object {
|
||||
if ($_ -and $_.Source) { $_.Source } else { $_ }
|
||||
} | Where-Object { $_ })
|
||||
if ($ImportType -eq 'alwaysImport') { return $loaded }
|
||||
|
||||
$files = @($ImportPolicies | Where-Object { $_ })
|
||||
$allLoaded = -not $script:GraphPagingCache
|
||||
$key = "$SameTenant|$allLoaded|$($loaded.Count)|" + (($files | ForEach-Object { "$($_.PolicyType.Id)/$($_.Id)/$($_.Name)" }) -join '|')
|
||||
if ($script:_importCandidateCache -and $script:_importCandidateCache.Key -eq $key) { return $script:_importCandidateCache.Value }
|
||||
|
||||
$value = @(Get-IntuneImportCandidates -ImportPolicies $files -LoadedPolicies $loaded -ImportType $ImportType -SameTenant $SameTenant -AllLoaded:$allLoaded)
|
||||
$script:_importCandidateCache = @{ Key = $key; Value = $value }
|
||||
return $value
|
||||
}
|
||||
|
||||
function Update-IntuneManagerImportMatch
|
||||
{
|
||||
# Operates on $script:_imImportFormState. Recomputes ImportAction /
|
||||
@@ -34,12 +62,8 @@ function Update-IntuneManagerImportMatch
|
||||
|
||||
$importType = [string]$st.Settings.ImportType
|
||||
$sameTenant = [bool]$st.Settings.SameTenant
|
||||
$existing = @()
|
||||
if ($script:dgIntuneManagerObjects) {
|
||||
$existing = @($script:dgIntuneManagerObjects.ItemsSource | ForEach-Object {
|
||||
if ($_ -and $_.Source) { $_.Source } else { $_ }
|
||||
} | Where-Object { $_ })
|
||||
}
|
||||
$files = @($st.DG.ItemsSource | ForEach-Object { if ($_) { $_.Source } })
|
||||
$existing = @(Get-IntuneManagerImportExistingPolicies -ImportPolicies $files -ImportType $importType -SameTenant $sameTenant)
|
||||
|
||||
foreach ($row in @($st.DG.ItemsSource)) {
|
||||
if (-not $row -or -not $row.Source) { continue }
|
||||
@@ -147,6 +171,8 @@ function Invoke-IntuneManagerImportLoad
|
||||
|
||||
function Show-IntuneManagerImportForm
|
||||
{
|
||||
# A new dialog looks candidates up afresh: an earlier import may have created some.
|
||||
$script:_importCandidateCache = $null
|
||||
$ui = $script:UIProvider
|
||||
$policyTypes = Get-IntuneManagerSelectedPolicyTypes
|
||||
|
||||
@@ -368,12 +394,8 @@ function Invoke-IntuneManagerImportExecute
|
||||
Update-IntuneManagerImportMatch
|
||||
$script:_imImportFormState = $null
|
||||
|
||||
$existing = @()
|
||||
if ($script:dgIntuneManagerObjects) {
|
||||
$existing = @($script:dgIntuneManagerObjects.ItemsSource | ForEach-Object {
|
||||
if ($_ -and $_.Source) { $_.Source } else { $_ }
|
||||
} | Where-Object { $_ })
|
||||
}
|
||||
$allFiles = @($st.DG.ItemsSource | ForEach-Object { if ($_) { $_.Source } })
|
||||
$existing = @(Get-IntuneManagerImportExistingPolicies -ImportPolicies $allFiles -ImportType $importType -SameTenant ([bool]$st.Settings.SameTenant))
|
||||
|
||||
$policiesToImport = @()
|
||||
$updatedPolicies = @()
|
||||
|
||||
@@ -30,7 +30,10 @@
|
||||
|
||||
<TextBlock Name="txtTitle" FontWeight="Bold" Margin="0,5,0,0"/>
|
||||
|
||||
<TextBlock Grid.Row="1" Text="(c) 2022 Mikael Karlsson - MIT License" Margin="0,5,0,0"/>
|
||||
<!-- Text set from the module manifest's Copyright by Show-AboutDialog
|
||||
(Get-AppCopyright). Do not hardcode a year here: this line read
|
||||
"(c) 2022" in 2026 builds, and so did the WPF copy. -->
|
||||
<TextBlock Grid.Row="1" Name="txtCopyright" Margin="0,5,0,0"/>
|
||||
|
||||
<StackPanel Grid.Row="2" Margin="0,5,0,0">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
|
||||
@@ -76,6 +76,7 @@
|
||||
<Separator/>
|
||||
<MenuItem Header="_Release Notes" Name="mnuUpdates"/>
|
||||
<MenuItem Header="_About" Name="mnuAbout"/>
|
||||
<MenuItem Header="_Hide console" Name="mnuToggleConsole"/>
|
||||
<Separator/>
|
||||
<MenuItem Header="_Exit" Name="mnuExit"/>
|
||||
</MenuItem>
|
||||
|
||||
Reference in New Issue
Block a user