Skip to content

Commit f85fa25

Browse files
authored
Merge pull request #121 from KelvinTegelaar/dev
[pull] dev from KelvinTegelaar:dev
2 parents 923b6db + 821bbe1 commit f85fa25

File tree

9 files changed

+81
-28
lines changed

9 files changed

+81
-28
lines changed

.github/workflows/upload_dev.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Upload Dev zip
2+
3+
on:
4+
push:
5+
branches:
6+
- dev
7+
8+
jobs:
9+
release:
10+
if: github.event.repository.fork == false && github.event_name == 'push'
11+
name: Upload to Azure
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
# Checkout the repository
16+
- name: Checkout Code
17+
uses: actions/checkout@v3
18+
19+
# Create ZIP File in a New Source Directory
20+
- name: Prepare and Zip Release Files
21+
run: |
22+
mkdir -p src/releases
23+
zip -r src/releases/dev.zip . \
24+
--exclude "./src/releases/*" \
25+
--exclude ".*" \
26+
--exclude ".*/**"
27+
28+
# Upload to Azure Blob Storage
29+
- name: Azure Blob Upload with Destination folder defined
30+
uses: LanceMcCarthy/[email protected]
31+
with:
32+
connection_string: ${{ secrets.AZURE_CONNECTION_STRING }}
33+
container_name: cipp-api
34+
source_folder: src/releases/
35+
destination_folder: /
36+
delete_if_exists: true

Modules/CIPPCore/Public/Add-CIPPScheduledTask.ps1

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,15 @@ function Add-CIPPScheduledTask {
6464
if ([int64]$task.ScheduledTime -eq 0 -or [string]::IsNullOrEmpty($task.ScheduledTime)) {
6565
$task.ScheduledTime = [int64](([datetime]::UtcNow) - (Get-Date '1/1/1970')).TotalSeconds
6666
}
67-
67+
$excludedTenants = if ($task.excludedTenants.value) {
68+
$task.excludedTenants.value -join ','
69+
}
6870
$entity = @{
6971
PartitionKey = [string]'ScheduledTask'
7072
TaskState = [string]'Planned'
7173
RowKey = [string]$RowKey
7274
Tenant = $task.TenantFilter.value ? "$($task.TenantFilter.value)" : "$($task.TenantFilter)"
75+
excludedTenants = [string]$excludedTenants
7376
Name = [string]$task.Name
7477
Command = [string]$task.Command.value
7578
Parameters = [string]$Parameters

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/CIPP/Scheduler/Invoke-AddScheduledItem.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Function Invoke-AddScheduledItem {
1414
} else {
1515
$hidden = $true
1616
}
17-
$Result = Add-CIPPScheduledTask -Task $Request.body -Headers $Request.Headers -hidden $hidden -DisallowDuplicateName $Request.query.DisallowDuplicateName
17+
$Result = Add-CIPPScheduledTask -Task $Request.body -Headers $Request.Headers -hidden $hidden -DisallowDuplicateName $Request.query.DisallowDuplicateName
1818
Write-LogMessage -headers $Request.Headers -API $APINAME -message $Result -Sev 'Info'
1919

2020
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Tenant/Administration/Alerts/Invoke-AddAlert.ps1

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,17 @@ Function Invoke-AddAlert {
1414
$Tenants = $request.body.tenantFilter
1515
$Conditions = $request.body.conditions | ConvertTo-Json -Compress -Depth 10 | Out-String
1616
$TenantsJson = $Tenants | ConvertTo-Json -Compress -Depth 10 | Out-String
17+
$excludedTenantsJson = $request.body.excludedTenants | ConvertTo-Json -Compress -Depth 10 | Out-String
1718
$Actions = $request.body.actions | ConvertTo-Json -Compress -Depth 10 | Out-String
1819
$RowKey = $Request.body.RowKey ? $Request.body.RowKey : (New-Guid).ToString()
1920
$CompleteObject = @{
20-
Tenants = [string]$TenantsJson
21-
Conditions = [string]$Conditions
22-
Actions = [string]$Actions
23-
type = $request.body.logbook.value
24-
RowKey = $RowKey
25-
PartitionKey = 'Webhookv2'
21+
Tenants = [string]$TenantsJson
22+
excludedTenants = [string]$excludedTenantsJson
23+
Conditions = [string]$Conditions
24+
Actions = [string]$Actions
25+
type = $request.body.logbook.value
26+
RowKey = $RowKey
27+
PartitionKey = 'Webhookv2'
2628
}
2729
$WebhookTable = get-cipptable -TableName 'WebhookRules'
2830
Add-CIPPAzDataTableEntity @WebhookTable -Entity $CompleteObject -Force

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Tenant/Administration/Alerts/Invoke-ListAlertsQueue.ps1

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,16 @@ Function Invoke-ListAlertsQueue {
3131
$TranslatedActions = ($Task.Actions | ConvertFrom-Json -Depth 10 -ErrorAction SilentlyContinue).label -join ','
3232
$Tenants = ($Task.Tenants | ConvertFrom-Json -Depth 10 -ErrorAction SilentlyContinue)
3333
$TaskEntry = [PSCustomObject]@{
34-
Tenants = @($Tenants.label)
35-
Conditions = $TranslatedConditions
36-
Actions = $TranslatedActions
37-
LogType = $Task.type
38-
EventType = 'Audit log Alert'
39-
RowKey = $Task.RowKey
40-
PartitionKey = $Task.PartitionKey
41-
RepeatsEvery = 'When received'
42-
RawAlert = @{
34+
Tenants = @($Tenants.label)
35+
Conditions = $TranslatedConditions
36+
excludedTenants = ($Task.excludedTenants | ConvertFrom-Json -Depth 10 -ErrorAction SilentlyContinue)
37+
Actions = $TranslatedActions
38+
LogType = $Task.type
39+
EventType = 'Audit log Alert'
40+
RowKey = $Task.RowKey
41+
PartitionKey = $Task.PartitionKey
42+
RepeatsEvery = 'When received'
43+
RawAlert = @{
4344
Conditions = @($Conditions)
4445
Actions = @($($Task.Actions | ConvertFrom-Json -Depth 10 -ErrorAction SilentlyContinue))
4546
Tenants = @($Tenants)
@@ -64,15 +65,16 @@ Function Invoke-ListAlertsQueue {
6465

6566
foreach ($Task in $ScheduledTasks) {
6667
$TaskEntry = [PSCustomObject]@{
67-
RowKey = $Task.RowKey
68-
PartitionKey = $Task.PartitionKey
69-
Tenants = @($Task.Tenant)
70-
Conditions = $Task.Name
71-
Actions = $Task.PostExecution
72-
LogType = 'Scripted'
73-
EventType = 'Scheduled Task'
74-
RepeatsEvery = $Task.Recurrence
75-
RawAlert = $Task
68+
RowKey = $Task.RowKey
69+
PartitionKey = $Task.PartitionKey
70+
excludedTenants = $Task.excludedTenants
71+
Tenants = @($Task.Tenant)
72+
Conditions = $Task.Name
73+
Actions = $Task.PostExecution
74+
LogType = 'Scripted'
75+
EventType = 'Scheduled Task'
76+
RepeatsEvery = $Task.Recurrence
77+
RawAlert = $Task
7678
}
7779
if ($AllowedTenants -notcontains 'AllTenants') {
7880
$Tenant = $TenantList | Where-Object -Property defaultDomainName -EQ $Task.Tenant

Modules/CIPPCore/Public/Entrypoints/Orchestrator Functions/Start-UserTasksOrchestrator.ps1

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ function Start-UserTasksOrchestrator {
3535
}
3636

3737
if ($task.Tenant -eq 'AllTenants') {
38-
$AllTenantCommands = foreach ($Tenant in $TenantList) {
38+
$ExcludedTenants = $task.excludedTenants -split ','
39+
Write-Host "Excluded Tenants from this task: $ExcludedTenants"
40+
$AllTenantCommands = foreach ($Tenant in $TenantList | Where-Object { $_.defaultDomainName -notin $ExcludedTenants }) {
3941
$NewParams = $task.Parameters.Clone()
4042
if ((Get-Command $task.Command).Parameters.TenantFilter) {
4143
$NewParams.TenantFilter = $Tenant.defaultDomainName

Modules/CIPPCore/Public/Set-CIPPIntunePolicy.ps1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ function Set-CIPPIntunePolicy {
1717
$ReplaceMap = Get-CIPPAzDataTableEntity @ReplaceTable -Filter "PartitionKey eq '$tenantFilter'"
1818
if ($ReplaceMap) {
1919
foreach ($Replace in $ReplaceMap) {
20-
$RawJSON = $RawJSON -replace $Replace.RowKey, $Replace.Value
20+
$String = '%{0}%' -f $Replace.RowKey
21+
$RawJSON = $RawJSON -replace $String, $Replace.Value
2122
}
2223
}
2324
#default replacements for all tenants: %tenantid% becomes $tenant.customerId, %tenantfilter% becomes $tenant.defaultDomainName, %tenantname% becomes $tenant.displayName

Modules/CIPPCore/Public/Webhooks/Test-CIPPAuditLogRules.ps1

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ function Test-CIPPAuditLogRules {
3434
$Configuration = $ConfigEntries | Where-Object { ($_.Tenants -match $TenantFilter -or $_.Tenants -match 'AllTenants') } | ForEach-Object {
3535
[pscustomobject]@{
3636
Tenants = ($_.Tenants | ConvertFrom-Json)
37+
Excluded = ($_.excludedTenants | ConvertFrom-Json -ErrorAction SilentlyContinue)
3738
Conditions = $_.Conditions
3839
Actions = $_.Actions
3940
LogType = $_.Type
@@ -180,6 +181,9 @@ function Test-CIPPAuditLogRules {
180181
#write-warning "Creating filters - $(($ProcessedData.operation | Sort-Object -Unique) -join ',') - $($TenantFilter)"
181182

182183
$Where = $Configuration | ForEach-Object {
184+
if ($TenantFilter -In $_.Excluded.value) {
185+
return
186+
}
183187
$conditions = $_.Conditions | ConvertFrom-Json | Where-Object { $_.Input.value -ne '' }
184188
$actions = $_.Actions
185189
$conditionStrings = [System.Collections.Generic.List[string]]::new()

Modules/CippExtensions/Public/Sherweb/Set-SherwebSubscription.ps1

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ function Set-SherwebSubscription {
3535
}
3636
$OrderUri = "https://api.sherweb.com/service-provider/v1/orders?customerId=$CustomerId"
3737
$Order = Invoke-RestMethod -Uri $OrderUri -Method POST -Headers $AuthHeader -Body $OrderBody -ContentType 'application/json'
38+
if ($Order -match 'Internal Server Error' -and $Add -gt 0) {
39+
throw 'An error occurred while attempting to create a new subscription. Please check the Cumulus portal to ensure this customer has been provisioned for Microsoft 365.'
40+
}
3841
return $Order
3942

4043
} else {

0 commit comments

Comments
 (0)