Skip to content

Commit 7d5e940

Browse files
authored
Merge pull request #115 from KelvinTegelaar/dev
[pull] dev from KelvinTegelaar:dev
2 parents b031e34 + bec3cbe commit 7d5e940

File tree

9 files changed

+33
-27
lines changed

9 files changed

+33
-27
lines changed

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/CIPP/Core/Invoke-ExecSetCIPPAutoBackup.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Function Invoke-ExecSetCIPPAutoBackup {
1515
Write-LogMessage -headers $Headers -API $APIName -message 'Accessed this API' -Sev 'Debug'
1616

1717
$unixtime = [int64](([datetime]::UtcNow) - (Get-Date '1/1/1970')).TotalSeconds
18-
if ($Request.Body.Enabled -eq 'True') {
18+
if ($Request.Body.Enabled -eq $true) {
1919
$Table = Get-CIPPTable -TableName 'ScheduledTasks'
2020
$AutomatedCIPPBackupTask = Get-AzDataTableEntity @table -Filter "Name eq 'Automated CIPP Backup'"
2121
$task = @{

Modules/CIPPCore/Public/Entrypoints/Invoke-ListCSPsku.ps1

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,19 @@ Function Invoke-ListCSPsku {
1414
Write-LogMessage -headers $Request.Headers -API $APINAME -message 'Accessed this API' -Sev 'Debug'
1515
$TenantFilter = $Request.Query.tenantFilter
1616

17-
if ($Request.Query.currentSkuOnly) {
18-
$GraphRequest = Get-SherwebCurrentSubscription -TenantFilter $TenantFilter
19-
} else {
20-
$GraphRequest = Get-SherwebCatalog -TenantFilter $TenantFilter
17+
try {
18+
if ($Request.Query.currentSkuOnly) {
19+
$GraphRequest = Get-SherwebCurrentSubscription -TenantFilter $TenantFilter
20+
} else {
21+
$GraphRequest = Get-SherwebCatalog -TenantFilter $TenantFilter
22+
}
23+
} catch {
24+
$GraphRequest = [PSCustomObject]@{
25+
name = @(@{value = 'Error getting catalog' })
26+
sku = $_.Exception.Message
27+
}
2128
}
2229

23-
2430
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
2531
StatusCode = [HttpStatusCode]::OK
2632
Body = @($GraphRequest)

Modules/CIPPCore/Public/GraphHelper/New-ExoRequest.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function New-ExoRequest {
3131
[Parameter(ParameterSetName = 'AvailableCmdlets')]
3232
[switch]$AvailableCmdlets,
3333

34-
$ModuleVersion = '3.5.1',
34+
$ModuleVersion = '3.7.1',
3535
[switch]$AsApp
3636
)
3737
if ((Get-AuthorisedRequest -TenantID $tenantid) -or $NoAuthCheck -eq $True) {

Modules/CIPPCore/Public/Webhooks/Invoke-CIPPWebhookProcessing.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ function Invoke-CippWebhookProcessing {
8585
}
8686
$LogId = Send-CIPPAlert @CIPPAlert
8787

88-
$AuditLogLink = '{0}/tenant/administration/audit-logs/log?logId={2}' -f $CIPPURL, $LogId
88+
$AuditLogLink = '{0}/tenant/administration/audit-logs/log?logId={1}&tenantFilter={2}' -f $CIPPURL, $LogId, $Tenant.defaultDomainName
8989
$GenerateEmail = New-CIPPAlertTemplate -format 'html' -data $Data -ActionResults $ActionResults -CIPPURL $CIPPURL -Tenant $Tenant.defaultDomainName -AuditLogLink $AuditLogLink
9090

9191
Write-Host 'Going to create the content'

Modules/CippExtensions/Public/Sherweb/Get-SherwebCatalog.ps1

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,18 @@ function Get-SherwebCatalog {
44
[string]$CustomerId,
55
[string]$TenantFilter
66
)
7+
78
if ($TenantFilter) {
8-
Get-ExtensionMapping -Extension 'Sherweb' | Where-Object { $_.RowKey -eq $TenantFilter } | ForEach-Object {
9-
Write-Host "Extracted customer id from tenant filter - It's $($_.IntegrationId)"
10-
$CustomerId = $_.IntegrationId
11-
}
9+
$TenantFilter = (Get-Tenants -TenantFilter $TenantFilter).customerId
10+
$CustomerId = Get-ExtensionMapping -Extension 'Sherweb' | Where-Object { $_.RowKey -eq $TenantFilter } | Select-Object -ExpandProperty IntegrationId
11+
}
12+
13+
if (![string]::IsNullOrEmpty($CustomerId)) {
14+
Write-Information "Getting catalog for $CustomerId"
15+
$AuthHeader = Get-SherwebAuthentication
16+
$SubscriptionsList = Invoke-RestMethod -Uri "https://api.sherweb.com/service-provider/v1/customer-catalogs/$CustomerId" -Method GET -Headers $AuthHeader
17+
return $SubscriptionsList.catalogItems
18+
} else {
19+
throw 'No Sherweb mapping found'
1220
}
13-
$AuthHeader = Get-SherwebAuthentication
14-
$SubscriptionsList = Invoke-RestMethod -Uri "https://api.sherweb.com/service-provider/v1/customer-catalogs/$CustomerId" -Method GET -Headers $AuthHeader
15-
return $SubscriptionsList.catalogItems
1621
}

Modules/CippExtensions/Public/Sherweb/Get-SherwebCurrentSubscription.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ function Get-SherwebCurrentSubscription {
1111
$CustomerId = Get-ExtensionMapping -Extension 'Sherweb' | Where-Object { $_.RowKey -eq $TenantFilter } | Select-Object -ExpandProperty IntegrationId
1212
}
1313

14+
Write-Information "Getting current subscription for $CustomerId"
1415
$AuthHeader = Get-SherwebAuthentication
1516
$Uri = "https://api.sherweb.com/service-provider/v1/billing/subscriptions/details?customerId=$CustomerId"
1617
$SubscriptionDetails = Invoke-RestMethod -Uri $Uri -Method GET -Headers $AuthHeader

Modules/CippExtensions/Public/Sherweb/Get-SherwebCustomerConfiguration.ps1

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@ function Get-SherwebCustomerConfiguration {
55
[string]$TenantFilter
66
)
77
if ($TenantFilter) {
8-
Get-ExtensionMapping -Extension 'Sherweb' | Where-Object { $_.RowKey -eq $TenantFilter } | ForEach-Object {
9-
Write-Host "Extracted customer id from tenant filter - It's $($_.IntegrationId)"
10-
$CustomerId = $_.IntegrationId
11-
}
8+
$TenantFilter = (Get-Tenants -TenantFilter $TenantFilter).customerId
9+
$CustomerId = Get-ExtensionMapping -Extension 'Sherweb' | Where-Object { $_.RowKey -eq $TenantFilter } | Select-Object -ExpandProperty IntegrationId
1210
}
1311
$AuthHeader = Get-SherwebAuthentication
1412
$Uri = "https://api.sherweb.com/service-provider/v1/customers/$($CustomerId)/platforms-configurations/"

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@ function Remove-SherwebSubscription {
77
[string]$TenantFilter
88
)
99
if ($TenantFilter) {
10-
Get-ExtensionMapping -Extension 'Sherweb' | Where-Object { $_.RowKey -eq $TenantFilter } | ForEach-Object {
11-
Write-Host "Extracted customer id from tenant filter - It's $($_.IntegrationId)"
12-
$CustomerId = $_.IntegrationId
13-
}
10+
$TenantFilter = (Get-Tenants -TenantFilter $TenantFilter).customerId
11+
$CustomerId = Get-ExtensionMapping -Extension 'Sherweb' | Where-Object { $_.RowKey -eq $TenantFilter } | Select-Object -ExpandProperty IntegrationId
1412
}
1513
$AuthHeader = Get-SherwebAuthentication
1614
$Body = ConvertTo-Json -Depth 10 -InputObject @{

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,8 @@ function Set-SherwebSubscription {
1010
[string]$TenantFilter
1111
)
1212
if ($TenantFilter) {
13-
Get-ExtensionMapping -Extension 'Sherweb' | Where-Object { $_.RowKey -eq $TenantFilter } | ForEach-Object {
14-
Write-Host "Extracted customer id from tenant filter - It's $($_.IntegrationId)"
15-
$CustomerId = $_.IntegrationId
16-
}
13+
$TenantFilter = (Get-Tenants -TenantFilter $TenantFilter).customerId
14+
$CustomerId = Get-ExtensionMapping -Extension 'Sherweb' | Where-Object { $_.RowKey -eq $TenantFilter } | Select-Object -ExpandProperty IntegrationId
1715
}
1816
$AuthHeader = Get-SherwebAuthentication
1917
$ExistingSubscription = Get-SherwebCurrentSubscription -CustomerId $CustomerId -SKU $SKU

0 commit comments

Comments
 (0)