Skip to content

Commit

Permalink
Tidy tenant list, optimize query
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnDuprey committed Apr 1, 2024
1 parent 4135bd3 commit a17af34
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
5 changes: 2 additions & 3 deletions Modules/CIPPCore/Public/GraphHelper/Get-Tenants.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function Get-Tenants {
if (!$LastRefresh -or $LastRefresh -lt (Get-Date).Addhours(-24).ToUniversalTime()) {

# Query for active relationships
$GDAPRelationships = New-GraphGetRequest -uri "https://graph.microsoft.com/beta/tenantRelationships/delegatedAdminRelationships?`$filter=status eq 'active'&`$select=customer,autoExtendDuration,endDateTime"
$GDAPRelationships = New-GraphGetRequest -uri "https://graph.microsoft.com/beta/tenantRelationships/delegatedAdminRelationships?`$filter=status eq 'active' and not startsWith(displayName,'MLT_')&`$select=customer,autoExtendDuration,endDateTime"

# Flatten gdap relationship
$GDAPList = foreach ($Relationship in $GDAPRelationships) {
Expand Down Expand Up @@ -115,6 +115,5 @@ function Get-Tenants {
Add-CIPPAzDataTableEntity @TenantsTable -Entity $IncludedTenantsCache
}
}
return ($IncludedTenantsCache | Where-Object -Property defaultDomainName -NE $null | Sort-Object -Property displayName)

return ($IncludedTenantsCache | Where-Object { $null -ne $_.defaultDomainName -and ($_.defaultDomainName -notmatch 'Domain Error' -or $IncludeAll.IsPresent) } | Sort-Object -Property displayName)
}
6 changes: 3 additions & 3 deletions Modules/CippExtensions/Private/Get-HaloMapping.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function Get-HaloMapping {
Get-CIPPAzDataTableEntity @CIPPMapping -Filter $Filter | ForEach-Object {
$Mappings | Add-Member -NotePropertyName $_.RowKey -NotePropertyValue @{ label = "$($_.HaloPSAName)"; value = "$($_.HaloPSA)" }
}
$Tenants = Get-Tenants -IncludeAll
$Tenants = Get-Tenants -IncludeErrors
$Table = Get-CIPPTable -TableName Extensionsconfig
try {
$Configuration = ((Get-CIPPAzDataTableEntity @Table).config | ConvertFrom-Json -ea stop).HaloPSA
Expand All @@ -30,9 +30,9 @@ function Get-HaloMapping {
} else {
$_.Exception.message
}

Write-LogMessage -Message "Could not get HaloPSA Clients, error: $Message " -Level Error -tenant 'CIPP' -API 'HaloMapping'
$RawHaloClients = @(@{name = "Could not get HaloPSA Clients, error: $Message" })
$RawHaloClients = @(@{name = "Could not get HaloPSA Clients, error: $Message" })
}
$HaloClients = $RawHaloClients | ForEach-Object {
[PSCustomObject]@{
Expand Down

0 comments on commit a17af34

Please sign in to comment.