forked from KelvinTegelaar/CIPP-API
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1a5eb93
commit f140018
Showing
15 changed files
with
220 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"bindings": [ | ||
{ | ||
"authLevel": "anonymous", | ||
"type": "httpTrigger", | ||
"direction": "in", | ||
"name": "Request", | ||
"methods": [ | ||
"get", | ||
"post" | ||
] | ||
}, | ||
{ | ||
"type": "http", | ||
"direction": "out", | ||
"name": "Response" | ||
}, | ||
{ | ||
"name": "starter", | ||
"direction": "in", | ||
"type": "durableClient" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using namespace System.Net | ||
|
||
# Input bindings are passed in via param block. | ||
param($Request, $TriggerMetadata) | ||
|
||
$APIName = $TriggerMetadata.FunctionName | ||
Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug" | ||
|
||
Write-Host "PowerShell HTTP trigger function processed a request." | ||
|
||
$Tenants = ($Request.body | Select-Object Select_*).psobject.properties.value | ||
$Results = foreach ($Tenant in $tenants) { | ||
try { | ||
$CompleteObject = [PSCustomObject]@{ | ||
tenant = $tenant | ||
AdminPassword = $Request.body.AdminPassword | ||
DefenderMalware = $Request.body.DefenderMalware | ||
DefenderStatus = $Request.body.DefenderStatus | ||
DisableRestart = $Request.body.DisableRestart | ||
InstallAsSystem = $Request.body.InstallAsSystem | ||
MFAAdmins = $Request.body.MFAAdmins | ||
MFAAlertUsers = $Request.body.MFAAlertUsers | ||
NewApprovedApp = $Request.body.NewApprovedApp | ||
NewGA = $Request.body.NewGA | ||
NewRole = $Request.body.NewRole | ||
QuotaUsed = $Request.body.QuotaUsed | ||
UnusedLicenses = $Request.body.UnusedLicenses | ||
Type = "Alert" | ||
|
||
} | ConvertTo-Json | ||
$JSONFile = New-Item -Path ".\Cache_Scheduler\$tenant.alert.json" -Value $CompleteObject -Force -ErrorAction Stop | ||
"Succesfully added Alert for $($Tenant) to queue." | ||
Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $tenant -message "Succesfully added Alert for $($Tenant) to queue." -Sev "Info" | ||
} | ||
catch { | ||
Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $tenant -message "Failed to add Alert for for $($Tenant) to queue" -Sev "Error" | ||
"Failed to add Alert for for $($Tenant) to queue" | ||
} | ||
} | ||
|
||
$body = [pscustomobject]@{"Results" = @($results) } | ||
|
||
# Associate values to output bindings by calling 'Push-OutputBinding'. | ||
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{ | ||
StatusCode = [HttpStatusCode]::OK | ||
Body = $body | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"bindings": [ | ||
{ | ||
"name": "tenant", | ||
"direction": "in", | ||
"type": "activityTrigger" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
param($tenant) | ||
|
||
try { | ||
#$Alerts = Get-Content ".\Cache_Scheduler\$tenant.alert.json" | ConvertFrom-Json | ||
Write-Host "GENERATING ALERT!!!!" | ||
#Write-Host $Alerts | ||
} | ||
catch { | ||
Log-request -API "Scheduler" -tenant $tenant -message "Failed to get alerts for $($tenant) Error: $($_.exception.message)" -sev Error | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"addStandardsDeploy": true, | ||
"webhook": "mywebhook.com", | ||
"addPolicy": true, | ||
"email": "[email protected]", | ||
"addChocoApp": true, | ||
"addUser": true, | ||
"removeUser": true, | ||
"removeStandard": true, | ||
"tokenUpdater": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"bindings": [ | ||
{ | ||
"name": "tenant", | ||
"direction": "in", | ||
"type": "activityTrigger" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"bindings": [ | ||
{ | ||
"name": "name", | ||
"type": "activityTrigger", | ||
"direction": "in" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
param($name) | ||
|
||
$Tenants = Get-ChildItem "Cache_Scheduler\*.json" | ||
|
||
$object = foreach ($Tenant in $tenants) { | ||
$TypeFile = Get-Content "$($tenant)" | ConvertFrom-Json | ||
if ($Typefile.Tenant -ne "AllTenants") { | ||
[pscustomobject]@{ | ||
Tenant = $Typefile.Tenant | ||
Type = $Typefile.Type | ||
} | ||
} | ||
else { | ||
Write-Host "All tenants, doing them all" | ||
get-tenants | ForEach-Object { | ||
[pscustomobject]@{ | ||
Tenant = $_.defaultDomainName | ||
Type = $Typefile.Type | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
||
$object |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"bindings": [ | ||
{ | ||
"name": "Context", | ||
"type": "orchestrationTrigger", | ||
"direction": "in" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
param($Context) | ||
|
||
New-Item "Cache_Scheduler" -ItemType Directory -ErrorAction SilentlyContinue | ||
New-Item "Cache_Scheduler\CurrentlyRunning.txt" -ItemType File -Force | ||
|
||
|
||
$Batch = (Invoke-DurableActivity -FunctionName 'Scheduler_GetQueue' -Input 'LetsGo') | ||
$ParallelTasks = foreach ($Item in $Batch) { | ||
Invoke-DurableActivity -FunctionName "Scheduler_$($item['Type'])" -Input $item['Tenant'] -NoWait | ||
} | ||
|
||
$Outputs = Wait-ActivityFunction -Task $ParallelTasks | ||
Write-Host $Outputs | ||
Remove-Item "Cache_Scheduler\CurrentlyRunning.txt" -Force | ||
Log-request -API "Scheduler" -tenant $tenant -message "Scheduler Ran." -sev Info |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"bindings": [ | ||
{ | ||
"name": "Timer", | ||
"schedule": "0 */15 * * * *", | ||
"direction": "in", | ||
"type": "timerTrigger" | ||
}, | ||
{ | ||
"name": "starter", | ||
"type": "durableClient", | ||
"direction": "in" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
using namespace System.Net | ||
|
||
param($Timer) | ||
|
||
$InstanceId = Start-NewOrchestration -FunctionName 'Scheduler_Orchestration' | ||
Write-Host "Started orchestration with ID = '$InstanceId'" | ||
New-OrchestrationCheckStatusResponse -Request $timer -InstanceId $InstanceId | ||
|
This file was deleted.
Oops, something went wrong.