Skip to content

Commit

Permalink
add temporary API
Browse files Browse the repository at this point in the history
  • Loading branch information
KelvinTegelaar committed Aug 8, 2024
1 parent 52282f7 commit d9b0957
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
})
}
4 changes: 3 additions & 1 deletion Modules/CIPPCore/Public/Test-CIPPRerun.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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.
}
Expand Down

0 comments on commit d9b0957

Please sign in to comment.