Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ function Invoke-ExecApiClient {
'GetAzureConfiguration' {
$Owner = $env:WEBSITE_OWNER_NAME
Write-Information "Owner: $Owner"
if ($Owner -match '^(?<SubscriptionId>[^+]+)\+(?<RGName>[^-]+(?:-[^-]+)*?)(?:-[^-]+webspace(?:-Linux)?)?$') {
if ($env:WEBSITE_SKU -ne 'FlexConsumption' -and $Owner -match '^(?<SubscriptionId>[^+]+)\+(?<RGName>[^-]+(?:-[^-]+)*?)(?:-[^-]+webspace(?:-Linux)?)?$') {
$RGName = $Matches.RGName
} else {
$RGName = $env:WEBSITE_RESOURCE_GROUP
Expand All @@ -123,7 +123,7 @@ function Invoke-ExecApiClient {
'SaveToAzure' {
$TenantId = $env:TenantID
$Owner = $env:WEBSITE_OWNER_NAME
if ($Owner -match '^(?<SubscriptionId>[^+]+)\+(?<RGName>[^-]+(?:-[^-]+)*?)(?:-[^-]+webspace(?:-Linux)?)?$') {
if ($env:WEBSITE_SKU -ne 'FlexConsumption' -and $Owner -match '^(?<SubscriptionId>[^+]+)\+(?<RGName>[^-]+(?:-[^-]+)*?)(?:-[^-]+webspace(?:-Linux)?)?$') {
$RGName = $Matches.RGName
} else {
$RGName = $env:WEBSITE_RESOURCE_GROUP
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Function Invoke-ExecBackendURLs {
function Invoke-ExecBackendURLs {
<#
.FUNCTIONALITY
Entrypoint
Expand All @@ -14,7 +14,7 @@ Function Invoke-ExecBackendURLs {
Write-Host 'PowerShell HTTP trigger function processed a request.'

$Owner = $env:WEBSITE_OWNER_NAME
if ($Owner -match '^(?<SubscriptionId>[^+]+)\+(?<RGName>[^-]+(?:-[^-]+)*?)(?:-[^-]+webspace(?:-Linux)?)?$') {
if ($env:WEBSITE_SKU -ne 'FlexConsumption' -and $Owner -match '^(?<SubscriptionId>[^+]+)\+(?<RGName>[^-]+(?:-[^-]+)*?)(?:-[^-]+webspace(?:-Linux)?)?$') {
$RGName = $Matches.RGName
} else {
$RGName = $env:WEBSITE_RESOURCE_GROUP
Expand Down
22 changes: 20 additions & 2 deletions Modules/CIPPCore/Public/GraphHelper/Get-Tenants.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,19 @@ function Get-Tenants {
}

if ($CleanOld.IsPresent) {
$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
try {
$GDAPRelationships = New-GraphGetRequest -uri "https://graph.microsoft.com/beta/tenantRelationships/delegatedAdminRelationships?`$filter=status eq 'active'&`$select=customer,autoExtendDuration,endDateTime" -NoAuthCheck:$true
# Filter out MLT relationships locally
$GDAPRelationships = $GDAPRelationships | Where-Object { $_.displayName -notlike 'MLT_*' }
if (!$GDAPRelationships) {
Write-LogMessage -API 'Get-Tenants' -message 'Tried cleaning old tenants but failed to get GDAP relationships - No relationships returned' -Sev 'Critical'
throw 'Failed to get GDAP relationships for cleaning old tenants.'
}
} catch {
$ErrorMessage = Get-CippException -Exception $_
Write-LogMessage -API 'Get-Tenants' -message "Tried cleaning old tenants but failed to get GDAP relationships - $($_.Exception.Message)" -Sev 'Critical' -LogData $ErrorMessage
throw $_
}
$GDAPList = foreach ($Relationship in $GDAPRelationships) {
[PSCustomObject]@{
customerId = $Relationship.customer.tenantId
Expand All @@ -84,7 +96,13 @@ function Get-Tenants {
throw 'RefreshToken not set. Cannot get tenant list.'
}
#get the full list of tenants
$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
$GDAPRelationships = New-GraphGetRequest -uri "https://graph.microsoft.com/v1.0/tenantRelationships/delegatedAdminRelationships?`$filter=status eq 'active'$RelationshipFilter&`$select=customer,autoExtendDuration,endDateTime" -NoAuthCheck:$true
# Filter out MLT relationships locally
$GDAPRelationships = $GDAPRelationships | Where-Object { $_.displayName -notlike 'MLT_*' }
Write-Host "GDAP relationships found: $($GDAPRelationships.Count)"
Write-Information "GDAP relationships found: $($GDAPRelationships.Count)"
$totalTenants = $GDAPRelationships.customer.tenantId | Select-Object -Unique
Write-Information "Total tenants found in relationships result: $($totalTenants.count)"
$GDAPList = foreach ($Relationship in $GDAPRelationships) {
[PSCustomObject]@{
customerId = $Relationship.customer.tenantId
Expand Down
2 changes: 1 addition & 1 deletion version_latest.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8.6.1
8.6.2