Get-Branding.ps1

function Get-Branding {
    $Completed = 0
    Write-Progress -Activity "Processing 0/$($Tenants.Count)" -Status "0% completed" -PercentComplete 0
    Import-module Microsoft.Graph.Identity.DirectoryManagement 
    $Tenants = Get-Tenants

    $Tenants | ForEach-Object {
        $Percent = [Math]::Floor($Completed / $Tenants.Count * 100)
        $Tenant = $_
        try {
            Write-Progress -Activity "Processing $($Tenant.DefaultDomainName) - $($Completed)/$($Tenants.Count)" -Status "$($Percent)% completed" -PercentComplete $Percent
            Connect-CustomerGraph -CustomerTenantId $Tenant.CustomerId
            $Branding = Get-MgOrganizationBranding -OrganizationId $Tenant.CustomerId -ErrorAction SilentlyContinue

                if( !$Branding ) {
                    Write-Host "Processing $($Tenant.DefaultDomainName)" -NoNewline
                    Write-Host " - No branding found" -ForegroundColor Yellow -NoNewline
                    $Branding = New-MgOrganizationBrandingLocalization -OrganizationId $Tenant.CustomerId -SignInPageText '**Har du udfordringer med login?** Kontakt [Jysk IT](https://jyskit.dk) på 76 60 23 23' -ErrorAction SilentlyContinue
                    if ($Branding) {
                        Write-Host " - Created branding" -ForegroundColor Green
                    }                  
                    
                }
                else {
                    if ( $Branding.SignInPageText -eq '') {
                        Write-Host "$($Tenant.DefaultDomainName) - Found empty branding ($($Branding.SignInPageText))" -ForegroundColor Green
                    }
                }
        }
        catch {
        }

        $Completed += 1
    }

    Write-Progress -Activity "Processed $($Completed)/$($Tenants.Count)" -Status "100% completed" -PercentComplete 100
}

Get-Branding