From d9b0957d6e12664bb73a6de80875991f74a50068 Mon Sep 17 00:00:00 2001 From: KelvinTegelaar Date: Thu, 8 Aug 2024 15:48:29 +0200 Subject: [PATCH] add temporary API --- .../BPA/Push-BPACollectData.ps1 | 5 ++++ .../Activity Triggers/Push-CIPPStandard.ps1 | 4 +-- .../Users/Invoke-ExecPerUserMFAAllUsers.ps1 | 29 +++++++++++++++++++ Modules/CIPPCore/Public/Test-CIPPRerun.ps1 | 4 ++- 4 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Identity/Administration/Users/Invoke-ExecPerUserMFAAllUsers.ps1 diff --git a/Modules/CIPPCore/Public/Entrypoints/Activity Triggers/BPA/Push-BPACollectData.ps1 b/Modules/CIPPCore/Public/Entrypoints/Activity Triggers/BPA/Push-BPACollectData.ps1 index af2c6092ff21..22f2217264de 100644 --- a/Modules/CIPPCore/Public/Entrypoints/Activity Triggers/BPA/Push-BPACollectData.ps1 +++ b/Modules/CIPPCore/Public/Entrypoints/Activity Triggers/BPA/Push-BPACollectData.ps1 @@ -19,6 +19,11 @@ function Push-BPACollectData { } } $Table = Get-CippTable -tablename 'cachebpav2' + $Rerun = Test-CIPPRerun -Type BPA -Tenant $TenantName -API $Item.Template + if ($Rerun) { + Write-Host 'Detected rerun. Exiting cleanly' + exit 0 + } Write-Host "Working on BPA for $($TenantName.displayName) with GUID $($TenantName.customerId) - Report ID $($Item.Template)" $Template = $Templates | Where-Object -Property Name -EQ -Value $Item.Template # Build up the result object that will be stored in tables diff --git a/Modules/CIPPCore/Public/Entrypoints/Activity Triggers/Push-CIPPStandard.ps1 b/Modules/CIPPCore/Public/Entrypoints/Activity Triggers/Push-CIPPStandard.ps1 index 44a46d8adb9f..964cd1d9294e 100644 --- a/Modules/CIPPCore/Public/Entrypoints/Activity Triggers/Push-CIPPStandard.ps1 +++ b/Modules/CIPPCore/Public/Entrypoints/Activity Triggers/Push-CIPPStandard.ps1 @@ -12,12 +12,12 @@ function Push-CIPPStandard { $Standard = $Item.Standard $FunctionName = 'Invoke-CIPPStandard{0}' -f $Standard Write-Host "We'll be running $FunctionName" - $Rerun = Test-CIPPRerun -Type Standard -Tenant $Tenant -Settings $Settings -API $Standard + $Rerun = Test-CIPPRerun -Type Standard -Tenant $Tenant -Settings $Item.Settings -API $Standard if ($Rerun) { Write-Host 'Detected rerun. Exiting cleanly' exit 0 } else { - Write-Host "Rerun is set to true. We'll be running $FunctionName" + Write-Host "Rerun is set to false. We'll be running $FunctionName" } try { & $FunctionName -Tenant $Item.Tenant -Settings $Item.Settings -ErrorAction Stop diff --git a/Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Identity/Administration/Users/Invoke-ExecPerUserMFAAllUsers.ps1 b/Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Identity/Administration/Users/Invoke-ExecPerUserMFAAllUsers.ps1 new file mode 100644 index 000000000000..f91b1f3a5a89 --- /dev/null +++ b/Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Identity/Administration/Users/Invoke-ExecPerUserMFAAllUsers.ps1 @@ -0,0 +1,29 @@ +function Invoke-ExecPerUserMFAAllUsers { + <# + .FUNCTIONALITY + Entrypoint + + .ROLE + Identity.User.ReadWrite + #> + Param( + $Request, + $TriggerMetadata + ) + $TenantFilter = $request.query.TenantFilter + $Users = New-GraphGetRequest -uri 'https://graph.microsoft.com/beta/users' -tenantid $TenantFilter + $Request = @{ + userId = $Users.id + TenantFilter = $tenantfilter + State = $Request.query.State + executingUser = $Request.Headers.'x-ms-client-principal' + } + $Result = Set-CIPPPerUserMFA @Request + $Body = @{ + Results = @($Result) + } + Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{ + StatusCode = [HttpStatusCode]::OK + Body = $Body + }) +} diff --git a/Modules/CIPPCore/Public/Test-CIPPRerun.ps1 b/Modules/CIPPCore/Public/Test-CIPPRerun.ps1 index aad186642fd7..f8cf9fba94ad 100644 --- a/Modules/CIPPCore/Public/Test-CIPPRerun.ps1 +++ b/Modules/CIPPCore/Public/Test-CIPPRerun.ps1 @@ -18,8 +18,10 @@ function Test-CIPPRerun { $RerunData = Get-CIPPAzDataTableEntity @RerunTable -filter "PartitionKey eq '$($TenantFilter)' and RowKey eq '$($Type)_$($API)'" if ($RerunData) { if ($Settings -and $RerunData.Settings) { + Write-Host 'Testing rerun settings' $PreviousSettings = $RerunData.Settings | ConvertFrom-Json -ErrorAction SilentlyContinue - $CompareSettings = Compare-Object -ReferenceObject $Settings -DifferenceObject $PreviousSettings + $CompareSettings = Compare-Object -ReferenceObject $Settings -DifferenceObject $PreviousSettings -ErrorAction SilentlyContinue + Write-Host "Compare settings is: $($CompareSettings | ConvertTo-Json -Compress -Depth 10)" if ($CompareSettings) { return $false # Not a rerun because settings have changed. }