Skip to content

Commit 14aba09

Browse files
sherweb mapping
1 parent d3de3b1 commit 14aba09

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/CIPP/Extensions/Invoke-ExecExtensionMapping.ps1

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ Function Invoke-ExecExtensionMapping {
3535
'HuduFields' {
3636
$Body = Get-HuduFieldMapping -CIPPMapping $Table
3737
}
38+
'Sherweb' {
39+
$Body = Get-SherwebMapping -CIPPMapping $Table
40+
}
3841
}
3942
}
4043

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
function Get-SherwebMapping {
2+
[CmdletBinding()]
3+
param (
4+
$CIPPMapping
5+
)
6+
7+
$ExtensionMappings = Get-ExtensionMapping -Extension 'Sherweb'
8+
9+
$Tenants = Get-Tenants -IncludeErrors
10+
11+
$Mappings = foreach ($Mapping in $ExtensionMappings) {
12+
$Tenant = $Tenants | Where-Object { $_.RowKey -eq $Mapping.RowKey }
13+
if ($Tenant) {
14+
[PSCustomObject]@{
15+
TenantId = $Tenant.customerId
16+
Tenant = $Tenant.displayName
17+
TenantDomain = $Tenant.defaultDomainName
18+
IntegrationId = $Mapping.IntegrationId
19+
IntegrationName = $Mapping.IntegrationName
20+
}
21+
}
22+
}
23+
$Tenants = Get-Tenants -IncludeErrors
24+
try {
25+
$SherwebCustomers = Get-SherwebCustomers
26+
27+
} catch {
28+
$Message = if ($_.ErrorDetails.Message) {
29+
Get-NormalizedError -Message $_.ErrorDetails.Message
30+
} else {
31+
$_.Exception.message
32+
}
33+
34+
Write-LogMessage -Message "Could not get Sherweb Companies, error: $Message " -Level Error -tenant 'CIPP' -API 'SherwebMapping'
35+
$SherwebCustomers = @(@{name = "Could not get Sherweb Companies, error: $Message"; value = '-1' })
36+
}
37+
$SherwebCustomers = $SherwebCustomers | ForEach-Object {
38+
[PSCustomObject]@{
39+
name = $_.displayName
40+
value = "$($_.id)"
41+
}
42+
}
43+
$MappingObj = [PSCustomObject]@{
44+
Companies = @($SherwebCustomers)
45+
Mappings = $Mappings
46+
}
47+
48+
return $MappingObj
49+
50+
}

0 commit comments

Comments
 (0)