Skip to content

Commit

Permalink
convert to string for backup tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
KelvinTegelaar committed Jul 5, 2024
1 parent 6e0cfeb commit 634f645
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ Function Invoke-ExecListBackup {
[CmdletBinding()]
param($Request, $TriggerMetadata)

$Result = Get-CIPPBackup -type $Request.body.Type -TenantFilter $Request.body.TenantFilter
$Result = Get-CIPPBackup -type $Request.query.Type -TenantFilter $Request.query.TenantFilter
if ($request.query.NameOnly) {
$Result = $Result | Select-Object RowKey, timestamp
}
Write-LogMessage -user $request.headers.'x-ms-client-principal' -API 'Alerts' -message $request.body.text -Sev $request.body.Severity
# Associate values to output bindings by calling 'Push-OutputBinding'.
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
Expand Down
8 changes: 4 additions & 4 deletions Modules/CIPPCore/Public/New-CIPPBackup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ function New-CIPPBackup {
RowKey = $RowKey
TenantFilter = $TenantFilter
}
Write-Host "ScheduledBackupValues: $($ScheduledBackupValues | ConvertTo-Json -Compress -Depth 100)"
Write-Host "Scheduled backup value psproperties: $($ScheduledBackupValues.psobject.Properties.Name)"
foreach ($ScheduledBackup in $ScheduledBackupValues.psobject.Properties.Name) {
$entity[$ScheduledBackup] = New-CIPPBackupTask -Task $ScheduledBackup -TenantFilter $TenantFilter
Write-Host "Scheduled backup value psproperties: $(([pscustomobject]$ScheduledBackupValues).psobject.Properties)"
foreach ($ScheduledBackup in ([pscustomobject]$ScheduledBackupValues).psobject.Properties.Name) {
$BackupResult = New-CIPPBackupTask -Task $ScheduledBackup -TenantFilter $TenantFilter | ConvertTo-Json -Depth 100 -Compress | Out-String
$entity[$ScheduledBackup] = "$BackupResult"
}
$Table = Get-CippTable -tablename 'ScheduledBackup'
try {
Expand Down
24 changes: 16 additions & 8 deletions Modules/CIPPCore/Public/New-CIPPBackupTask.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,24 @@ function New-CIPPBackupTask {

$BackupData = switch ($Task) {
'users' {
$BackupData = New-GraphGetRequest -uri 'https://graph.microsoft.com/beta/users?$top=999' -tenantid $TenantFilter
Write-Host "Backup users for $TenantFilter"
New-GraphGetRequest -uri 'https://graph.microsoft.com/beta/users?$top=999' -tenantid $TenantFilter
}
'groups' {
$BackupData = New-GraphGetRequest -uri 'https://graph.microsoft.com/beta/groups?$top=999' -tenantid $TenantFilter
Write-Host "Backup groups for $TenantFilter"
New-GraphGetRequest -uri 'https://graph.microsoft.com/beta/groups?$top=999' -tenantid $TenantFilter
}
'ca' {
$BackupData = New-GraphGetRequest -uri 'https://graph.microsoft.com/beta/conditionalAccess/policies?$top=999' -tenantid $TenantFilter
Write-Host "Backup Conditional Access Policies for $TenantFilter"
New-GraphGetRequest -uri 'https://graph.microsoft.com/beta/conditionalAccess/policies?$top=999' -tenantid $TenantFilter
}
'namedlocations' {
$BackupData = New-GraphGetRequest -uri 'https://graph.microsoft.com/beta/conditionalAccess/namedLocations?$top=999' -tenantid $TenantFilter
Write-Host "Backup Named Locations for $TenantFilter"
New-GraphGetRequest -uri 'https://graph.microsoft.com/beta/conditionalAccess/namedLocations?$top=999' -tenantid $TenantFilter
}
'authstrengths' {
$BackupData = New-GraphGetRequest -uri 'https://graph.microsoft.com/beta/conditionalAccess/authenticationStrength/policies' -tenantid $TenantFilter
Write-Host "Backup Authentication Strength Policies for $TenantFilter"
New-GraphGetRequest -uri 'https://graph.microsoft.com/beta/conditionalAccess/authenticationStrength/policies' -tenantid $TenantFilter
}
'intuneconfig' {
#alert
Expand All @@ -29,17 +34,20 @@ function New-CIPPBackupTask {
'intuneprotection' {}

'CippWebhookAlerts' {
Write-Host "Backup Webhook Alerts for $TenantFilter"
$WebhookTable = Get-CIPPTable -TableName 'WebhookRules'
$BackupData = Get-CIPPAzDataTableEntity @WebhookTable | Where-Object { $TenantFilter -in ($_.Tenants | ConvertFrom-Json).fullvalue.defaultDomainName }
Get-CIPPAzDataTableEntity @WebhookTable | Where-Object { $TenantFilter -in ($_.Tenants | ConvertFrom-Json).fullvalue.defaultDomainName }
}
'CippScriptedAlerts' {
Write-Host "Backup Scripted Alerts for $TenantFilter"
$ScheduledTasks = Get-CIPPTable -TableName 'ScheduledTasks'
$BackupData = Get-CIPPAzDataTableEntity @ScheduledTasks | Where-Object { $_.hidden -eq $true -and $_.command -like 'Get-CippAlert*' -and $TenantFilter -in $_.Tenant }
Get-CIPPAzDataTableEntity @ScheduledTasks | Where-Object { $_.hidden -eq $true -and $_.command -like 'Get-CippAlert*' -and $TenantFilter -in $_.Tenant }
}
'CippStandards' {
Write-Host "Backup Standards for $TenantFilter"
$Table = Get-CippTable -tablename 'standards'
$Filter = "PartitionKey eq 'standards' and RowKey eq '$($TenantFilter)'"
$BackupData = (Get-CIPPAzDataTableEntity @Table -Filter $Filter)
(Get-CIPPAzDataTableEntity @Table -Filter $Filter)
}

}
Expand Down
2 changes: 1 addition & 1 deletion Scheduler_UserTasks/function.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"bindings": [
{
"name": "Timer",
"schedule": "0 */15 * * * *",
"schedule": "0 */5 * * * *",
"direction": "in",
"type": "timerTrigger"
},
Expand Down

0 comments on commit 634f645

Please sign in to comment.