Skip to content

Commit 10e7b1b

Browse files
committed
logging
1 parent abfeee8 commit 10e7b1b

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,19 +96,25 @@ function Get-Tenants {
9696

9797
$Alias = (Get-AzDataTableEntity @PropertiesTable -Filter "PartitionKey eq '$($_.Name)' and RowKey eq 'Alias'").Value
9898

99+
if ($Alias) {
100+
Write-Host "Alias found for $($_.Name) - $Alias."
101+
}
102+
99103
if ($TriggerRefresh.IsPresent -and $ExistingTenantInfo.customerId) {
100104
# Reset error count
101105
Write-Host "Resetting error count for $($_.Name)"
102106
$ExistingTenantInfo.GraphErrorCount = 0
103107
Add-CIPPAzDataTableEntity @TenantsTable -Entity $ExistingTenantInfo -Force | Out-Null
104108
}
105109

110+
$LatestRelationship = $_.Group | Sort-Object -Property relationshipEnd | Select-Object -Last 1
111+
106112
if ($ExistingTenantInfo -and $ExistingTenantInfo.RequiresRefresh -eq $false -and ($ExistingTenantInfo.displayName -eq $LatestRelationship.displayName -or $ExistingTenantInfo.displayName -eq $Alias)) {
107113
Write-Host 'Existing tenant found. We already have it cached, skipping.'
108114

109115
$DisplayNameUpdated = $false
110116
if (![string]::IsNullOrEmpty($Alias)) {
111-
if ($Alias.Value -ne $ExistingTenantInfo.displayName) {
117+
if ($Alias -ne $ExistingTenantInfo.displayName) {
112118
Write-Host "Alias found for $($_.Name)."
113119
$ExistingTenantInfo.displayName = $Alias
114120
$DisplayNameUpdated = $true
@@ -129,7 +135,7 @@ function Get-Tenants {
129135
$ExistingTenantInfo
130136
return
131137
}
132-
$LatestRelationship = $_.Group | Sort-Object -Property relationshipEnd | Select-Object -Last 1
138+
133139
$AutoExtend = ($_.Group | Where-Object { $_.autoExtend -eq $true } | Measure-Object).Count -gt 0
134140
if (!$SkipDomains.IsPresent) {
135141
try {
@@ -157,7 +163,7 @@ function Get-Tenants {
157163
Write-Host 'finished getting domain'
158164

159165
if (![string]::IsNullOrEmpty($Alias)) {
160-
Write-Host "Alias found for $($_.Name)."
166+
Write-Information "Setting display name to $Alias."
161167
$displayName = $Alias
162168
} else {
163169
$displayName = $LatestRelationship.displayName

0 commit comments

Comments
 (0)