From 03b27b1775a5a888231d5a717b72c4c3cc4444c4 Mon Sep 17 00:00:00 2001 From: Mikael Karlsson <43226266+Micke-K@users.noreply.github.com> Date: Sat, 11 Oct 2025 13:40:24 +1100 Subject: [PATCH] 3.10.1.4 Issue 364 - Paging issues Issue 367 - Login with App in UI --- Extensions/EndpointManager.psm1 | 33 +++++++++++++++++++++++++++--- Extensions/MSALAuthentication.psm1 | 5 +++++ Extensions/MSGraph.psm1 | 30 ++++++++++++++++++++------- 3 files changed, 58 insertions(+), 10 deletions(-) diff --git a/Extensions/EndpointManager.psm1 b/Extensions/EndpointManager.psm1 index 7cc1229..caca5b8 100644 --- a/Extensions/EndpointManager.psm1 +++ b/Extensions/EndpointManager.psm1 @@ -204,6 +204,7 @@ function Invoke-InitializeModule Permissons=@("DeviceManagementConfiguration.ReadWrite.All") Dependencies = @("ReusableSettings") GroupId = "EndpointSecurity" + SupportsPageSize = $false }) Add-ViewItem (New-Object PSObject -Property @{ @@ -217,6 +218,7 @@ function Invoke-InitializeModule PostExportCommand = { Start-PostExportCompliancePolicies @args } PreUpdateCommand = { Start-PreUpdateCompliancePolicies @args } GroupId = "CompliancePolicies" + SupportsPageSize = $false }) Add-ViewItem (New-Object PSObject -Property @{ @@ -264,6 +266,7 @@ function Invoke-InitializeModule SkipRemoveProperties = @('Id') # Id is removed by PreImport. Required for default profile PropertiesToRemoveForUpdate = @('isDefaultProfile','disableClientTelemetry') GroupId = "TenantAdmin" + SupportsPageSize = $false }) <# @@ -291,6 +294,7 @@ function Invoke-InitializeModule GroupId = "Azure" SkipAddIDOnExport = $true ExpandAssignmentsList = $false + SupportsPageSize = $false }) Add-ViewItem (New-Object PSObject -Property @{ @@ -314,6 +318,7 @@ function Invoke-InitializeModule AssignmentsType = "enrollmentConfigurationAssignments" PropertiesToRemoveForUpdate = @('priority') GroupId = "WinEnrollment" + SupportsPageSize = $false }) Add-ViewItem (New-Object PSObject -Property @{ @@ -337,6 +342,7 @@ function Invoke-InitializeModule AssignmentsType = "enrollmentConfigurationAssignments" GroupId = "EnrollmentRestrictions" ViewProperties = @("displayName","platformType","description","Id") + SupportsPageSize = $false }) Add-ViewItem (New-Object PSObject -Property @{ @@ -352,6 +358,7 @@ function Invoke-InitializeModule SkipRemoveProperties = @('Id') GroupId = "WinEnrollment" Icon = "EnrollmentStatusPage" + SupportsPageSize = $false }) Add-ViewItem (New-Object PSObject -Property @{ @@ -428,6 +435,7 @@ function Invoke-InitializeModule PreImportAssignmentsCommand = { Start-PreImportAssignmentsTermsAndConditions @args } GroupId = "TenantAdmin" ExpandAssignmentsList = $false + SupportsPageSize = $false }) Add-ViewItem (New-Object PSObject -Property @{ @@ -448,6 +456,7 @@ function Invoke-InitializeModule Dependencies = @("Applications") GroupId = "AppProtection" ExpandAssignmentsList = $false + SupportsPageSize = $false }) # These are also included in the managedAppPolicies API @@ -467,6 +476,7 @@ function Invoke-InitializeModule Icon = "AppConfiguration" GroupId = "AppConfiguration" ExpandAssignmentsList = $false + SupportsPageSize = $false }) Add-ViewItem (New-Object PSObject -Property @{ @@ -578,6 +588,7 @@ function Invoke-InitializeModule Icon = "UpdatePolicies" GroupId = "WinQualityUpdates" PropertiesToRemoveForUpdate = @('releaseDateDisplayName','deployableContentDisplayName') + SupportsPageSize = $false }) # Locations are not FULLY supported @@ -647,7 +658,8 @@ function Invoke-InitializeModule API = "/deviceManagement/hardwareConfigurations" Permissons=@("DeviceManagementConfiguration.ReadWrite.All") Icon="DeviceConfiguration" - GroupId = "DeviceConfiguration" + GroupId = "DeviceConfiguration" + SupportsPageSize = $false }) Add-ViewItem (New-Object PSObject -Property @{ @@ -778,6 +790,7 @@ function Invoke-InitializeModule PreDeleteCommand = { Start-PreDeleteADMXFiles @args } ViewProperties = @("fileName","status","Id") PropertiesToRemove = @("languageCodes","targetPrefix","targetNamespace","policyType","revision","status","uploadDateTime") + SupportsPageSize = $false }) <# @@ -1058,7 +1071,14 @@ function Set-EMViewPanel $global:btnLoadAllPages.add_click({ Write-Status "Loading $($global:curObjectType.Title) objects" [array]$graphObjects = Get-GraphObjects -property $global:curObjectType.ViewProperties -objectType $global:curObjectType -AllPages - $graphObjects | Where-Object { $_ -ne $null } | ForEach-Object { $global:dgObjects.ItemsSource.AddNewItem($_) | Out-Null } + if(-not $global:dgObjects.Columns) + { + Show-GraphObjects -FromGraphObjects $graphObjects + } + else + { + $graphObjects | Where-Object { $_ -ne $null } | ForEach-Object { $global:dgObjects.ItemsSource.AddNewItem($_) | Out-Null } + } $global:dgObjects.ItemsSource.CommitNew() Set-GraphPagesButtonStatus Invoke-FilterBoxChanged $global:txtFilter -ForceUpdate @@ -1068,7 +1088,14 @@ function Set-EMViewPanel $global:btnLoadNextPage.add_click({ Write-Status "Loading $($global:curObjectType.Title) objects" [array]$graphObjects = Get-GraphObjects -property $global:curObjectType.ViewProperties -objectType $global:curObjectType -SinglePage - $graphObjects | Where-Object { $_ -ne $null } | ForEach-Object { $global:dgObjects.ItemsSource.AddNewItem($_) | Out-Null } + if(-not $global:dgObjects.Columns) + { + Show-GraphObjects -FromGraphObjects $graphObjects + } + else + { + $graphObjects | Where-Object { $_ -ne $null } | ForEach-Object { $global:dgObjects.ItemsSource.AddNewItem($_) | Out-Null } + } $global:dgObjects.ItemsSource.CommitNew() Set-GraphPagesButtonStatus Invoke-FilterBoxChanged $global:txtFilter diff --git a/Extensions/MSALAuthentication.psm1 b/Extensions/MSALAuthentication.psm1 index bff4791..56acc23 100644 --- a/Extensions/MSALAuthentication.psm1 +++ b/Extensions/MSALAuthentication.psm1 @@ -1025,6 +1025,11 @@ function Connect-MSALUser if($global:MainAppStarted -eq $false) { $script:AppLogin = (Get-SettingValue "GraphAzureAppLogin") -or ($global:TenantId -and $global:AzureAppId -and ($global:ClientSecret -or $global:ClientCert)) + + if((Get-SettingValue "GraphAzureAppLogin") -and -not $global:TenantId) + { + $global:TenantId = Get-SettingValue "GraphAzureTenantId" + } } if($script:AppLogin) diff --git a/Extensions/MSGraph.psm1 b/Extensions/MSGraph.psm1 index d1e5f61..d642a12 100644 --- a/Extensions/MSGraph.psm1 +++ b/Extensions/MSGraph.psm1 @@ -215,7 +215,7 @@ function Invoke-InitializeModule DefaultValue = $true Description = "This will export/import info for referenced/navigation properties eg certificates in VPN profiles etc." }) "ImportExport" - + Add-SettingsObject (New-Object PSObject -Property @{ Title = "ApplicationId" Key = "GraphAzureAppId" @@ -245,6 +245,13 @@ function Invoke-InitializeModule Description = "Login with specified app in the UI. Note: Change will require app restart" }) "GraphSilent" + Add-SettingsObject (New-Object PSObject -Property @{ + Title = "TenantId" + Key = "GraphAzureTenantId" + Type = "String" + Description = "Tenent Id used when logging in with App in UI" + }) "GraphSilent" + Add-SettingsObject (New-Object PSObject -Property @{ Title = "Refresh Objects after copy" Key = "RefreshObjectsAfterCopy" @@ -290,7 +297,7 @@ function Invoke-InitializeModule Key = "GraphPageSize" Type = "List" ItemsSource = $script:lstGraphPageSize - DefaultValue = "20" + DefaultValue = "100" Description = "How many items load at a time" }) "GraphGeneral" @@ -790,7 +797,7 @@ function Add-GraphObjectProperties function Show-GraphObjects { - param($filter, [switch]$ObjectTypeChanged) + param($filter, [switch]$ObjectTypeChanged, $FromGraphObjects) $global:curObjectType = $global:lstMenuItems.SelectedItem @@ -833,7 +840,9 @@ function Show-GraphObjects if(-not $global:lstMenuItems.SelectedItem) { return } - Write-Status "Loading $($global:curObjectType.Title) objects" + if(-not $FromGraphObjects) { + Write-Status "Loading $($global:curObjectType.Title) objects" + } if($global:lstMenuItems.SelectedItem.ShowForm -ne $false) { @@ -864,7 +873,7 @@ function Show-GraphObjects } elseif ($tmpPageSize -eq "All") { - $params.Add("AllPages", $true) + $params.Add("AllPages", $true) }else { @@ -882,7 +891,12 @@ function Show-GraphObjects $params.Add("SinglePage", $true) } - [array]$graphObjects = Get-GraphObjects -property $global:curObjectType.ViewProperties -objectType $global:curObjectType -Filter $filter @params + if($FromGraphObjects) { + [array]$graphObjects = $FromGraphObjects + } + else { + [array]$graphObjects = Get-GraphObjects -property $global:curObjectType.ViewProperties -objectType $global:curObjectType -Filter $filter @params + } $dgObjects.AutoGenerateColumns = $false $dgObjects.Columns.Clear() @@ -960,7 +974,9 @@ function Show-GraphObjects } else { - $dgObjects.ItemsSource = $null + $ocList = [System.Collections.ObjectModel.ObservableCollection[object]]::new() + $dgObjects.ItemsSource = [System.Windows.Data.CollectionViewSource]::GetDefaultView($ocList) + #$dgObjects.ItemsSource = $null }