diff --git a/Modules/CIPPCore/Public/Entrypoints/HTTP Functions/CIPP/Core/Invoke-ExecEditTemplate.ps1 b/Modules/CIPPCore/Public/Entrypoints/HTTP Functions/CIPP/Core/Invoke-ExecEditTemplate.ps1 index 61905a757faf..0d765e27a478 100644 --- a/Modules/CIPPCore/Public/Entrypoints/HTTP Functions/CIPP/Core/Invoke-ExecEditTemplate.ps1 +++ b/Modules/CIPPCore/Public/Entrypoints/HTTP Functions/CIPP/Core/Invoke-ExecEditTemplate.ps1 @@ -21,10 +21,10 @@ Function Invoke-ExecEditTemplate { if ($Type -eq 'IntuneTemplate') { Write-Host 'Intune Template' - $OriginalTemplate = Get-CIPPAzDataTableEntity @Table -Filter "PartitionKey eq 'IntuneTemplate' and GUID eq '$GUID'" + $OriginalTemplate = Get-CIPPAzDataTableEntity @Table -Filter "PartitionKey eq 'IntuneTemplate' and RowKey eq '$GUID'" $OriginalTemplate = ($OriginalTemplate.JSON | ConvertFrom-Json -Depth 100) $RawJSON = $OriginalTemplate.RAWJson - Set-CIPPIntuneTemplate -RawJSON $RawJSON -GUID $GUID -DisplayName $Request.body.displayName -Description $Request.body.description -templateType $Request.body.type + Set-CIPPIntuneTemplate -RawJSON $RawJSON -GUID $GUID -DisplayName $Request.body.displayName -Description $Request.body.description -templateType $OriginalTemplate.Type } else { $Table.Force = $true diff --git a/Modules/CIPPCore/Public/Entrypoints/HTTP Functions/CIPP/Core/Invoke-ListGraphRequest.ps1 b/Modules/CIPPCore/Public/Entrypoints/HTTP Functions/CIPP/Core/Invoke-ListGraphRequest.ps1 index 84de0b74395a..45bede27c0b2 100644 --- a/Modules/CIPPCore/Public/Entrypoints/HTTP Functions/CIPP/Core/Invoke-ListGraphRequest.ps1 +++ b/Modules/CIPPCore/Public/Entrypoints/HTTP Functions/CIPP/Core/Invoke-ListGraphRequest.ps1 @@ -122,7 +122,9 @@ function Invoke-ListGraphRequest { $Results = Get-GraphRequestList @GraphRequestParams if ($Results.nextLink) { Write-Host "NextLink: $($Results.nextLink | Select-Object -Last 1)" - $Metadata['nextLink'] = $Results.nextLink | Select-Object -Last 1 + if ($Request.Query.TenantFilter -ne 'AllTenants') { + $Metadata['nextLink'] = $Results.nextLink | Select-Object -Last 1 + } #Results is an array of objects, so we need to remove the last object before returning $Results = $Results | Select-Object -First ($Results.Count - 1) } diff --git a/Modules/CIPPCore/Public/Entrypoints/HTTP Functions/CIPP/Settings/Invoke-ExecWebhookSubscriptions.ps1 b/Modules/CIPPCore/Public/Entrypoints/HTTP Functions/CIPP/Settings/Invoke-ExecWebhookSubscriptions.ps1 index 86359bdd9572..c5cf687c5fc9 100644 --- a/Modules/CIPPCore/Public/Entrypoints/HTTP Functions/CIPP/Settings/Invoke-ExecWebhookSubscriptions.ps1 +++ b/Modules/CIPPCore/Public/Entrypoints/HTTP Functions/CIPP/Settings/Invoke-ExecWebhookSubscriptions.ps1 @@ -60,6 +60,26 @@ function Invoke-ExecWebhookSubscriptions { }) } } + 'UnsubscribeAll' { + $TenantList = Get-Tenants -IncludeErrors + $Results = foreach ($tenant in $TenantList) { + $TenantFilter = $tenant.defaultDomainName + $Subscriptions = New-GraphGetRequest -uri 'https://graph.microsoft.com/beta/subscriptions' -tenantid $TenantFilter | Where-Object { $_.notificationUrl -like '*PublicWebhooks*' } + "Unsubscribing from all CIPP subscriptions for $TenantFilter - $($Subscriptions.Count) subscriptions found" + $Subscriptions | ForEach-Object { + New-GraphPostRequest -uri "https://graph.microsoft.com/beta/subscriptions/$($_.id)" -tenantid $TenantFilter -type DELETE -body {} -Verbose + # get row from table if exists and remove + $Webhook = Get-AzDataTableEntity @Table -Filter "WebhookNotificationUrl eq 'https://graph.microsoft.com/beta/subscriptions/$($_.id)'" -Property PartitionKey, RowKey, ETag + if ($Webhook) { + $null = Remove-AzDataTableEntity -Force @Table -Entity $Webhook + } + } + } + Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{ + StatusCode = [HttpStatusCode]::OK + Body = @{ Results = $Results } + }) + } 'Resubscribe' { Write-Host "Resubscribing to $($Request.Query.WebhookID)" $Row = Get-AzDataTableEntity @Table -Filter "RowKey eq '$($Request.Query.WebhookID)'" diff --git a/Modules/CIPPCore/Public/GraphRequests/Get-GraphRequestList.ps1 b/Modules/CIPPCore/Public/GraphRequests/Get-GraphRequestList.ps1 index 0d376eda8f9a..98d09f7507c9 100644 --- a/Modules/CIPPCore/Public/GraphRequests/Get-GraphRequestList.ps1 +++ b/Modules/CIPPCore/Public/GraphRequests/Get-GraphRequestList.ps1 @@ -190,7 +190,7 @@ function Get-GraphRequestList { TenantFilter = $_.defaultDomainName Endpoint = $using:Endpoint Parameters = $using:Parameters - NoPagination = $using:NoPagination.IsPresent + NoPagination = $false ReverseTenantLookupProperty = $using:ReverseTenantLookupProperty ReverseTenantLookup = $using:ReverseTenantLookup.IsPresent NoAuthCheck = $using:NoAuthCheck.IsPresent diff --git a/Modules/CIPPCore/Public/Invoke-CIPPStandardsRun.ps1 b/Modules/CIPPCore/Public/Invoke-CIPPStandardsRun.ps1 index ea1e553903fe..2b2016230ad6 100644 --- a/Modules/CIPPCore/Public/Invoke-CIPPStandardsRun.ps1 +++ b/Modules/CIPPCore/Public/Invoke-CIPPStandardsRun.ps1 @@ -12,16 +12,13 @@ function Invoke-CIPPStandardsRun { $runManually = $false ) - Write-Host "Starting process for standards - $($tenantFilter)" + Write-Host "Starting process for standards - $($tenantFilter). TemplateID: $($TemplateID) RunManually: $($runManually) Force: $($Force.IsPresent)" $AllTasks = Get-CIPPStandards if ($Force.IsPresent) { Write-Host 'Clearing Rerun Cache' - foreach ($Task in $AllTasks) { - Write-Host "Clearing $($Task.Standard)_$($TemplateID)" - $null = Test-CIPPRerun -Type Standard -Tenant $Task.Tenant -API "$($Task.Standard)_$($TemplateID)" -Clear - } + Test-CIPPRerun -ClearAll -TenantFilter $TenantFilter -Type 'Standard' } #For each item in our object, run the queue. diff --git a/Modules/CIPPCore/Public/Standards/Get-CIPPStandards.ps1 b/Modules/CIPPCore/Public/Standards/Get-CIPPStandards.ps1 index 4bf96e3b2787..e69927b304d3 100644 --- a/Modules/CIPPCore/Public/Standards/Get-CIPPStandards.ps1 +++ b/Modules/CIPPCore/Public/Standards/Get-CIPPStandards.ps1 @@ -13,9 +13,9 @@ function Get-CIPPStandards { $Table = Get-CippTable -tablename 'templates' $Filter = "PartitionKey eq 'StandardsTemplateV2'" $Templates = (Get-CIPPAzDataTableEntity @Table -Filter $Filter | Sort-Object TimeStamp).JSON | ForEach-Object { - #in the string $_, replace the word 'action' by the word 'Action'. try { - $_ -replace 'Action', 'action' | ConvertFrom-Json -InputObject $_ -ErrorAction SilentlyContinue + $JSON = ($_).replace('"Action":', '"action":') #fix cap mistake of antique standards + ConvertFrom-Json -InputObject $JSON -ErrorAction SilentlyContinue } catch { } } | Where-Object { diff --git a/Modules/CIPPCore/Public/Test-CIPPRerun.ps1 b/Modules/CIPPCore/Public/Test-CIPPRerun.ps1 index b8e27a6b4269..39384ad879bc 100644 --- a/Modules/CIPPCore/Public/Test-CIPPRerun.ps1 +++ b/Modules/CIPPCore/Public/Test-CIPPRerun.ps1 @@ -6,7 +6,8 @@ function Test-CIPPRerun { $API, $Settings, $ExecutingUser, - [switch]$Clear + [switch]$Clear, + [switch]$ClearAll ) $RerunTable = Get-CIPPTable -tablename 'RerunCache' $EstimatedDifference = switch ($Type) { @@ -19,6 +20,12 @@ function Test-CIPPRerun { try { $RerunData = Get-CIPPAzDataTableEntity @RerunTable -filter "PartitionKey eq '$($TenantFilter)' and RowKey eq '$($Type)_$($API)'" + if ($ClearAll.IsPresent) { + $AllRerunData = Get-CIPPAzDataTableEntity @RerunTable + Remove-AzDataTableEntity @RerunTable -Entity $AllRerunData -Force + return $false + } + if ($Clear.IsPresent) { if ($RerunData) { Remove-AzDataTableEntity @RerunTable -Entity $RerunData diff --git a/version_latest.txt b/version_latest.txt index a3fcc7121bba..a8a188756826 100644 --- a/version_latest.txt +++ b/version_latest.txt @@ -1 +1 @@ -7.1.0 +7.1.2