Skip to content

Commit 5404a56

Browse files
committed
Merge branch 'dev' of https://github.com/KelvinTegelaar/CIPP-API into dev
2 parents 559fd18 + f687df2 commit 5404a56

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

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

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Function Invoke-ExecOffboardTenant {
1+
function Invoke-ExecOffboardTenant {
22
<#
33
.FUNCTIONALITY
44
Entrypoint
@@ -84,7 +84,7 @@ Function Invoke-ExecOffboardTenant {
8484
$property = $_
8585
$propertyContacts = $orgContacts.($($property))
8686

87-
if ($propertyContacts -AND ($domains -notcontains ($propertyContacts | ForEach-Object { $_.Split('@')[1] }))) {
87+
if ($propertyContacts -and ($domains -notcontains ($propertyContacts | ForEach-Object { $_.Split('@')[1] }))) {
8888
$newPropertyContent = [System.Collections.Generic.List[object]]($propertyContacts | Where-Object { $domains -notcontains $_.Split('@')[1] })
8989

9090
$patchContactBody = if (!($newPropertyContent)) { "{ `"$($property)`" : [] }" } else { [pscustomobject]@{ $property = $newPropertyContent } | ConvertTo-Json }
@@ -103,6 +103,29 @@ Function Invoke-ExecOffboardTenant {
103103
# TODO Add logic for privacyProfile later - rvdwegen
104104

105105
}
106+
107+
if ($request.body.RemoveDomainAnalyserData -eq $true) {
108+
# Remove all Domain Analyser data for this tenant
109+
try {
110+
$DomainTable = Get-CIPPTable -Table 'Domains'
111+
$Filter = "TenantGUID eq '{0}'" -f $TenantId
112+
$DomainEntries = Get-CIPPAzDataTableEntity @DomainTable -Filter $Filter
113+
114+
if ($DomainEntries) {
115+
$DomainCount = ($DomainEntries | Measure-Object).Count
116+
foreach ($Domain in $DomainEntries) {
117+
Remove-AzDataTableEntity @DomainTable -Entity $Domain
118+
}
119+
$Results.Add("Successfully removed $DomainCount Domain Analyser entries")
120+
Write-LogMessage -headers $Request.Headers -API $APIName -message "Removed $DomainCount Domain Analyser entries" -Sev 'Info' -tenant $TenantFilter
121+
} else {
122+
$Results.Add('No Domain Analyser data found for this tenant')
123+
}
124+
} catch {
125+
$Errors.Add("Failed to remove Domain Analyser data: $($_.Exception.message)")
126+
}
127+
}
128+
106129
$VendorApps = $Request.Body.vendorApplications
107130
if ($VendorApps) {
108131
$VendorApps | ForEach-Object {

0 commit comments

Comments
 (0)