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 pull request #45 from KelvinTegelaar/master
[pull] master from KelvinTegelaar:master
- Loading branch information
Showing
123 changed files
with
2,587 additions
and
3,013 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
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
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
File renamed without changes.
File renamed without changes.
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
59 changes: 59 additions & 0 deletions
59
...s/CIPPCore/Public/Entrypoints/HTTP Functions/CIPP/Extensions/Invoke-ListExtensionSync.ps1
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,59 @@ | ||
using namespace System.Net | ||
|
||
Function Invoke-ListExtensionSync { | ||
<# | ||
.FUNCTIONALITY | ||
Entrypoint | ||
.ROLE | ||
CIPP.Extension.Read | ||
#> | ||
[CmdletBinding()] | ||
param($Request, $TriggerMetadata) | ||
|
||
$APIName = $TriggerMetadata.FunctionName | ||
Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message 'Accessed this API' -Sev 'Debug' | ||
|
||
# Write to the Azure Functions log stream. | ||
Write-Host 'PowerShell HTTP trigger function processed a request.' | ||
$ScheduledTasksTable = Get-CIPPTable -TableName 'ScheduledTasks' | ||
$ScheduledTasks = Get-CIPPAzDataTableEntity @ScheduledTasksTable -Filter 'Hidden eq true' | Where-Object { $_.Command -match 'CippExtension' } | ||
|
||
$AllowedTenants = Test-CIPPAccess -Request $Request -TenantList | ||
$TenantList = Get-Tenants -IncludeErrors | ||
$AllTasksArrayList = [system.collections.generic.list[object]]::new() | ||
|
||
foreach ($Task in $ScheduledTasks) { | ||
if ($Task.Results -and (Test-Json -Json $Task.Results -ErrorAction SilentlyContinue)) { | ||
$Results = $Task.Results | ConvertFrom-Json | ||
} else { | ||
$Results = $Task.Results | ||
} | ||
|
||
$TaskEntry = [PSCustomObject]@{ | ||
RowKey = $Task.RowKey | ||
PartitionKey = $Task.PartitionKey | ||
Tenant = $Task.Tenant | ||
Name = $Task.Name | ||
SyncType = $Task.SyncType | ||
ScheduledTime = $Task.ScheduledTime | ||
ExecutedTime = $Task.ExecutedTime | ||
RepeatsEvery = $Task.Recurrence | ||
Results = $Results | ||
} | ||
|
||
if ($AllowedTenants -notcontains 'AllTenants') { | ||
$Tenant = $TenantList | Where-Object -Property defaultDomainName -EQ $Task.Tenant | ||
if ($AllowedTenants -contains $Tenant.customerId) { | ||
$AllTasksArrayList.Add($TaskEntry) | ||
} | ||
} else { | ||
$AllTasksArrayList.Add($TaskEntry) | ||
} | ||
} | ||
Write-Host ($AllTasksArrayList | ConvertTo-Json -Depth 5 -Compress) | ||
# Associate values to output bindings by calling 'Push-OutputBinding'. | ||
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{ | ||
StatusCode = [HttpStatusCode]::OK | ||
Body = ConvertTo-Json -Depth 5 -InputObject $($AllTasksArrayList) | ||
}) | ||
} |
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
Oops, something went wrong.