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.
Merge branch 'KelvinTegelaar:master' into master
- Loading branch information
Showing
1,037 changed files
with
36,233 additions
and
75,835 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,22 @@ | ||
# Editor configuration, see http://editorconfig.org | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
indent_style = space | ||
insert_final_newline = true | ||
|
||
[*.{ps1, psd1, psm1}] | ||
indent_size = 4 | ||
end_of_line = crlf | ||
trim_trailing_whitespace = true | ||
|
||
[*.json] | ||
indent_size = 2 | ||
end_of_line = crlf | ||
trim_trailing_whitespace = true | ||
|
||
[*.{md, txt}] | ||
end_of_line = crlf | ||
max_line_length = off | ||
trim_trailing_whitespace = false |
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
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,5 @@ | ||
{ | ||
"recommendations": [ | ||
"editorconfig.editorconfig" | ||
] | ||
} |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,23 +1,40 @@ | ||
using namespace System.Net | ||
|
||
param($Request, $TriggerMetadata) | ||
if ($CurrentlyRunning) { | ||
$Results = [pscustomobject]@{'Results' = 'Already running. Please wait for the current instance to finish' } | ||
Write-LogMessage -API 'BestPracticeAnalyser' -message 'Attempted to start analysis but an instance was already running.' -sev Info | ||
|
||
if ($Request.Query.TenantFilter) { | ||
$TenantList = @($Request.Query.TenantFilter) | ||
$Name = "Best Practice Analyser ($($Request.Query.TenantFilter))" | ||
} else { | ||
$InputObject = @{ | ||
TenantFilter = $Request.Query.TenantFilter | ||
$TenantList = Get-Tenants | ||
$Name = 'Best Practice Analyser (All Tenants)' | ||
} | ||
|
||
$BPATemplateTable = Get-CippTable -tablename 'templates' | ||
$Filter = "PartitionKey eq 'BPATemplate'" | ||
$Templates = ((Get-CIPPAzDataTableEntity @BPATemplateTable -Filter $Filter).JSON | ConvertFrom-Json).Name | ||
|
||
$BPAReports = foreach ($Tenant in $TenantList) { | ||
foreach ($Template in $Templates) { | ||
[PSCustomObject]@{ | ||
FunctionName = 'BPACollectData' | ||
Tenant = $Tenant.defaultDomainName | ||
Template = $Template | ||
QueueName = '{0} - {1}' -f $Template, $Tenant.defaultDomainName | ||
} | ||
} | ||
$InstanceId = Start-NewOrchestration -FunctionName 'BestPracticeAnalyser_Orchestration' -InputObject $InputObject | ||
Write-Host "Started orchestration with ID = '$InstanceId'" | ||
$Orchestrator = New-OrchestrationCheckStatusResponse -Request $Request -InstanceId $InstanceId | ||
Write-LogMessage -API 'BestPracticeAnalyser' -message 'Started retrieving best practice information' -sev Info | ||
$Results = [pscustomobject]@{'Results' = 'Started running analysis' } | ||
} | ||
Write-Host ($Orchestrator | ConvertTo-Json) | ||
|
||
$Queue = New-CippQueueEntry -Name $Name -TotalTasks ($BPAReports | Measure-Object).Count | ||
$BPAReports = $BPAReports | Select-Object *, @{Name = 'QueueId'; Expression = { $Queue.RowKey } } | ||
$InputObject = [PSCustomObject]@{ | ||
Batch = @($BPAReports) | ||
OrchestratorName = 'BPAOrchestrator' | ||
SkipLog = $true | ||
} | ||
Start-NewOrchestration -FunctionName 'CIPPOrchestrator' -InputObject ($InputObject | ConvertTo-Json -Compress -Depth 5) | ||
|
||
$Results = [pscustomobject]@{'Results' = 'BPA started' } | ||
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{ | ||
StatusCode = [HttpStatusCode]::OK | ||
Body = $results | ||
Body = $Results | ||
}) |
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 |
---|---|---|
@@ -1,23 +1,33 @@ | ||
param($Timer) | ||
|
||
if ($env:DEV_SKIP_BPA_TIMER) { | ||
if ($env:DEV_SKIP_BPA_TIMER) { | ||
Write-Host 'Skipping BPA timer' | ||
exit 0 | ||
exit 0 | ||
} | ||
|
||
try { | ||
$CurrentlyRunning = Get-Item 'Cache_BestPracticeAnalyser\CurrentlyRunning.txt' -ErrorAction SilentlyContinue | Where-Object -Property LastWriteTime -GT (Get-Date).AddHours(-24) | ||
if ($CurrentlyRunning) { | ||
$Results = [pscustomobject]@{'Results' = 'Already running. Please wait for the current instance to finish' } | ||
Write-LogMessage -API 'BestPracticeAnalyser' -message 'Attempted to start analysis but an instance was already running.' -sev Info | ||
} | ||
else { | ||
$InstanceId = Start-NewOrchestration -FunctionName 'BestPracticeAnalyser_Orchestration' | ||
Write-Host "Started orchestration with ID = '$InstanceId'" | ||
$Orchestrator = New-OrchestrationCheckStatusResponse -Request $Timer -InstanceId $InstanceId | ||
Write-LogMessage -API 'BestPracticeAnalyser' -message 'Started retrieving best practice information' -sev Info | ||
$Results = [pscustomobject]@{'Results' = 'Started running analysis' } | ||
$TenantList = Get-Tenants | ||
|
||
$BPATemplateTable = Get-CippTable -tablename 'templates' | ||
$Filter = "PartitionKey eq 'BPATemplate'" | ||
$Templates = ((Get-CIPPAzDataTableEntity @BPATemplateTable -Filter $Filter).JSON | ConvertFrom-Json).Name | ||
|
||
|
||
$BPAReports = foreach ($Tenant in $TenantList) { | ||
foreach ($Template in $Templates) { | ||
[PSCustomObject]@{ | ||
FunctionName = 'BPACollectData' | ||
Tenant = $Tenant.defaultDomainName | ||
Template = $Template | ||
QueueName = '{0} - {1}' -f $Template, $Tenant.defaultDomainName | ||
} | ||
} | ||
Write-Host ($Orchestrator | ConvertTo-Json) | ||
} | ||
catch { Write-Host "BestPracticeAnalyser_OrchestratorStarterTimer Exception $($_.Exception.Message)" } | ||
|
||
$Queue = New-CippQueueEntry -Name 'Best Practice Analyser' -TotalTasks ($BPAReports | Measure-Object).Count | ||
$BPAReports = $BPAReports | Select-Object *, @{Name = 'QueueId'; Expression = { $Queue.RowKey } } | ||
$InputObject = [PSCustomObject]@{ | ||
Batch = @($BPAReports) | ||
OrchestratorName = 'BPAOrchestrator' | ||
SkipLog = $true | ||
} | ||
Start-NewOrchestration -FunctionName 'CIPPOrchestrator' -InputObject ($InputObject | ConvertTo-Json -Compress -Depth 5) |
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
Oops, something went wrong.