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
261 changed files
with
1,173 additions
and
41,089 deletions.
There are no files selected for viewing
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,43 @@ | ||
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)' | ||
} | ||
$CippRoot = (Get-Item $PSScriptRoot).Parent.FullName | ||
$TemplatesLoc = Get-ChildItem "$CippRoot\Config\*.BPATemplate.json" | ||
$Templates = $TemplatesLoc | ForEach-Object { | ||
$Template = $(Get-Content $_) | ConvertFrom-Json | ||
$Template.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 | ||
DurableMode = 'Sequence' | ||
} | ||
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,36 @@ | ||
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 | ||
|
||
$CippRoot = (Get-Item $PSScriptRoot).Parent.FullName | ||
$TemplatesLoc = Get-ChildItem "$CippRoot\Config\*.BPATemplate.json" | ||
$Templates = $TemplatesLoc | ForEach-Object { | ||
$Template = $(Get-Content $_) | ConvertFrom-Json | ||
$Template.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 | ||
DurableMode = 'Sequence' | ||
} | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ | ||
"name": "CIPP Tenant Feature Licensing", | ||
"style": "Table", | ||
"Fields": [ | ||
{ | ||
"name": "AssignedPlans", | ||
"UseExistingInfo": false, | ||
"ExtractFields": ["AADPremiumService", "exchange", "SharePoint"], | ||
"FrontendFields": [ | ||
{ | ||
"name": "Entra ID Premium", | ||
"value": "AssignedPlans.AADPremiumService", | ||
"formatter": "bool" | ||
}, | ||
{ | ||
"name": "Exchange", | ||
"value": "AssignedPlans.exchange", | ||
"formatter": "bool" | ||
}, | ||
{ | ||
"name": "SharePoint", | ||
"value": "AssignedPlans.SharePoint", | ||
"formatter": "bool" | ||
} | ||
], | ||
"desc": "Entra ID Premium Status", | ||
"StoreAs": "JSON", | ||
"API": "CIPPFunction", | ||
"Command": "Get-CIPPTenantCapabilities", | ||
"Parameters": {} | ||
} | ||
] | ||
} |
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
Oops, something went wrong.