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:
@@ -133,8 +133,9 @@
|
||||
}
|
||||
}
|
||||
|
||||
if ($SinglePage -eq $true) { $newPageObject = $true }
|
||||
else { $params.Add("AllPages", $true) }
|
||||
# Page size "All" means every page, whatever the caller asked for (#384).
|
||||
if ($SinglePage -eq $true -and -not (Test-GraphPageSizeAll)) { $newPageObject = $true }
|
||||
else { $params.Add("AllPages", $true) }
|
||||
}
|
||||
elseif ($script:GraphPagingCache) {
|
||||
# Resume paging: cache stores the same {BatchObject,Types} / {ListURL,Types}
|
||||
|
||||
@@ -11,6 +11,7 @@ function Import-GraphPolicy {
|
||||
|
||||
Begin {
|
||||
Write-Log "Start Import of $(($InputObject | Measure-Object).Count) object(s)"
|
||||
$approvalsBefore = @(Get-MSGraphApprovalPending).Count
|
||||
$importedPolicies = @()
|
||||
$navigationPropObjects = @()
|
||||
|
||||
@@ -121,7 +122,17 @@ function Import-GraphPolicy {
|
||||
}
|
||||
}
|
||||
|
||||
Write-Log "Import finished. $($importedPolicies.Count) policies imported"
|
||||
# Writes Multi Admin Approval held are queued for a second administrator,
|
||||
# not failed - count them so the run doesn't read as "0 imported" (#442).
|
||||
$pendingApprovals = @(Get-MSGraphApprovalPending | Select-Object -Skip $approvalsBefore)
|
||||
$finishedText = "Import finished. $($importedPolicies.Count) policies imported"
|
||||
if ($pendingApprovals.Count -gt 0) {
|
||||
$finishedText += ", $($pendingApprovals.Count) waiting for Multi Admin Approval"
|
||||
}
|
||||
Write-Log $finishedText
|
||||
foreach ($pendingApproval in $pendingApprovals) {
|
||||
Write-Log "Waiting for Multi Admin Approval: $($pendingApproval.Method) $($pendingApproval.Url) - approval code $($pendingApproval.ApprovalCode)" 2
|
||||
}
|
||||
return $importedPolicies
|
||||
}
|
||||
}
|
||||
|
||||
@@ -547,6 +547,7 @@ function Invoke-MSGraphAPI {
|
||||
|
||||
if ($approvalInfo.IsApprovalPending) {
|
||||
Write-Log "$Url - $($approvalInfo.Advice)" 2
|
||||
Add-MSGraphApprovalPending -Method $HttpMethod -Url $Url -ApprovalCode $approvalInfo.ApprovalCode
|
||||
}
|
||||
else {
|
||||
if ($approvalInfo.Advice) { Write-Log $approvalInfo.Advice 2 }
|
||||
|
||||
@@ -51,7 +51,9 @@ function Start-GraphBulkImport {
|
||||
Start-GraphBulkImport -ImportFolder C:\IntuneExport -PolicyGroup DeviceConfiguration -Filter "Baseline"
|
||||
|
||||
.OUTPUTS
|
||||
PSCustomObject with summary statistics (Groups, Imported, Duration).
|
||||
PSCustomObject with summary statistics (Groups, Imported, Updated, Replaced,
|
||||
Skipped, PendingApproval, UnknownSelectors, Duration). PendingApproval counts
|
||||
the writes Multi Admin Approval held for a second administrator.
|
||||
#>
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
@@ -111,7 +113,7 @@ function Start-GraphBulkImport {
|
||||
}
|
||||
if ($targetGroups.Count -eq 0) {
|
||||
Write-Log "Bulk import: no policy groups selected" 2
|
||||
return [PSCustomObject]@{ Groups = 0; Imported = 0; UnknownSelectors = $unknownSelectors; Duration = $stopwatch.Elapsed }
|
||||
return [PSCustomObject]@{ Groups = 0; Imported = 0; PendingApproval = 0; UnknownSelectors = $unknownSelectors; Duration = $stopwatch.Elapsed }
|
||||
}
|
||||
|
||||
# Honour the ClearCacheBeforeExportImport setting (bit 4 = bulk import).
|
||||
@@ -136,6 +138,8 @@ function Start-GraphBulkImport {
|
||||
$totalUpdated = 0
|
||||
$totalReplaced = 0
|
||||
$totalSkipped = 0
|
||||
# Creates and updates Multi Admin Approval held: queued, not failed (#442).
|
||||
$approvalsBefore = @(Get-MSGraphApprovalPending).Count
|
||||
# Ascending ImportOrder so dependencies import before their dependents.
|
||||
$orderedGroups = @($targetGroups | Sort-Object { ($_.PolicyTypes | Measure-Object ImportOrder -Minimum).Minimum })
|
||||
$groupTotal = $orderedGroups.Count
|
||||
@@ -216,9 +220,15 @@ function Start-GraphBulkImport {
|
||||
}
|
||||
}
|
||||
|
||||
$totalPendingApproval = @(Get-MSGraphApprovalPending).Count - $approvalsBefore
|
||||
$finishedText = "Bulk import finished. $totalImported imported, $totalUpdated updated, $totalReplaced replaced, $totalSkipped skipped"
|
||||
if ($totalPendingApproval -gt 0) {
|
||||
$finishedText += ", $totalPendingApproval waiting for Multi Admin Approval"
|
||||
}
|
||||
|
||||
Write-Status $null
|
||||
Write-Log "****************************************************************"
|
||||
Write-Log "Bulk import finished. $totalImported imported, $totalUpdated updated, $totalReplaced replaced, $totalSkipped skipped"
|
||||
Write-Log $finishedText
|
||||
Write-Log "****************************************************************"
|
||||
|
||||
return [PSCustomObject]@{
|
||||
@@ -227,6 +237,7 @@ function Start-GraphBulkImport {
|
||||
Updated = $totalUpdated
|
||||
Replaced = $totalReplaced
|
||||
Skipped = $totalSkipped
|
||||
PendingApproval = $totalPendingApproval
|
||||
UnknownSelectors = $unknownSelectors
|
||||
Duration = $stopwatch.Elapsed
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user