Skip to content

Commit 2d672e4

Browse files
authored
Merge pull request #1687 from KelvinTegelaar/dev
Dev to hotfix
2 parents 5568a7b + 3433d05 commit 2d672e4

File tree

4 files changed

+25
-7
lines changed

4 files changed

+25
-7
lines changed

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/CIPP/Settings/Invoke-ExecApiClient.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ function Invoke-ExecApiClient {
101101
'GetAzureConfiguration' {
102102
$Owner = $env:WEBSITE_OWNER_NAME
103103
Write-Information "Owner: $Owner"
104-
if ($Owner -match '^(?<SubscriptionId>[^+]+)\+(?<RGName>[^-]+(?:-[^-]+)*?)(?:-[^-]+webspace(?:-Linux)?)?$') {
104+
if ($env:WEBSITE_SKU -ne 'FlexConsumption' -and $Owner -match '^(?<SubscriptionId>[^+]+)\+(?<RGName>[^-]+(?:-[^-]+)*?)(?:-[^-]+webspace(?:-Linux)?)?$') {
105105
$RGName = $Matches.RGName
106106
} else {
107107
$RGName = $env:WEBSITE_RESOURCE_GROUP
@@ -123,7 +123,7 @@ function Invoke-ExecApiClient {
123123
'SaveToAzure' {
124124
$TenantId = $env:TenantID
125125
$Owner = $env:WEBSITE_OWNER_NAME
126-
if ($Owner -match '^(?<SubscriptionId>[^+]+)\+(?<RGName>[^-]+(?:-[^-]+)*?)(?:-[^-]+webspace(?:-Linux)?)?$') {
126+
if ($env:WEBSITE_SKU -ne 'FlexConsumption' -and $Owner -match '^(?<SubscriptionId>[^+]+)\+(?<RGName>[^-]+(?:-[^-]+)*?)(?:-[^-]+webspace(?:-Linux)?)?$') {
127127
$RGName = $Matches.RGName
128128
} else {
129129
$RGName = $env:WEBSITE_RESOURCE_GROUP

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/CIPP/Settings/Invoke-ExecBackendURLs.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Function Invoke-ExecBackendURLs {
1+
function Invoke-ExecBackendURLs {
22
<#
33
.FUNCTIONALITY
44
Entrypoint
@@ -14,7 +14,7 @@ Function Invoke-ExecBackendURLs {
1414
Write-Host 'PowerShell HTTP trigger function processed a request.'
1515

1616
$Owner = $env:WEBSITE_OWNER_NAME
17-
if ($Owner -match '^(?<SubscriptionId>[^+]+)\+(?<RGName>[^-]+(?:-[^-]+)*?)(?:-[^-]+webspace(?:-Linux)?)?$') {
17+
if ($env:WEBSITE_SKU -ne 'FlexConsumption' -and $Owner -match '^(?<SubscriptionId>[^+]+)\+(?<RGName>[^-]+(?:-[^-]+)*?)(?:-[^-]+webspace(?:-Linux)?)?$') {
1818
$RGName = $Matches.RGName
1919
} else {
2020
$RGName = $env:WEBSITE_RESOURCE_GROUP

Modules/CIPPCore/Public/GraphHelper/Get-Tenants.ps1

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,19 @@ function Get-Tenants {
6060
}
6161

6262
if ($CleanOld.IsPresent) {
63-
$GDAPRelationships = New-GraphGetRequest -uri "https://graph.microsoft.com/beta/tenantRelationships/delegatedAdminRelationships?`$filter=status eq 'active' and not startsWith(displayName,'MLT_')&`$select=customer,autoExtendDuration,endDateTime&`$top=300" -NoAuthCheck:$true
63+
try {
64+
$GDAPRelationships = New-GraphGetRequest -uri "https://graph.microsoft.com/beta/tenantRelationships/delegatedAdminRelationships?`$filter=status eq 'active'&`$select=customer,autoExtendDuration,endDateTime" -NoAuthCheck:$true
65+
# Filter out MLT relationships locally
66+
$GDAPRelationships = $GDAPRelationships | Where-Object { $_.displayName -notlike 'MLT_*' }
67+
if (!$GDAPRelationships) {
68+
Write-LogMessage -API 'Get-Tenants' -message 'Tried cleaning old tenants but failed to get GDAP relationships - No relationships returned' -Sev 'Critical'
69+
throw 'Failed to get GDAP relationships for cleaning old tenants.'
70+
}
71+
} catch {
72+
$ErrorMessage = Get-CippException -Exception $_
73+
Write-LogMessage -API 'Get-Tenants' -message "Tried cleaning old tenants but failed to get GDAP relationships - $($_.Exception.Message)" -Sev 'Critical' -LogData $ErrorMessage
74+
throw $_
75+
}
6476
$GDAPList = foreach ($Relationship in $GDAPRelationships) {
6577
[PSCustomObject]@{
6678
customerId = $Relationship.customer.tenantId
@@ -84,7 +96,13 @@ function Get-Tenants {
8496
throw 'RefreshToken not set. Cannot get tenant list.'
8597
}
8698
#get the full list of tenants
87-
$GDAPRelationships = New-GraphGetRequest -uri "https://graph.microsoft.com/beta/tenantRelationships/delegatedAdminRelationships?`$filter=status eq 'active' and not startsWith(displayName,'MLT_')$RelationshipFilter&`$select=customer,autoExtendDuration,endDateTime&`$top=300" -NoAuthCheck:$true
99+
$GDAPRelationships = New-GraphGetRequest -uri "https://graph.microsoft.com/v1.0/tenantRelationships/delegatedAdminRelationships?`$filter=status eq 'active'$RelationshipFilter&`$select=customer,autoExtendDuration,endDateTime" -NoAuthCheck:$true
100+
# Filter out MLT relationships locally
101+
$GDAPRelationships = $GDAPRelationships | Where-Object { $_.displayName -notlike 'MLT_*' }
102+
Write-Host "GDAP relationships found: $($GDAPRelationships.Count)"
103+
Write-Information "GDAP relationships found: $($GDAPRelationships.Count)"
104+
$totalTenants = $GDAPRelationships.customer.tenantId | Select-Object -Unique
105+
Write-Information "Total tenants found in relationships result: $($totalTenants.count)"
88106
$GDAPList = foreach ($Relationship in $GDAPRelationships) {
89107
[PSCustomObject]@{
90108
customerId = $Relationship.customer.tenantId

version_latest.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8.6.1
1+
8.6.2

0 commit comments

Comments
 (0)