Get-CustomerAduditlogging.ps1

#426 processed
# Tjek om der er spamfilter.io connector.

function Get-CustomerAuditlogging {
    $Completed = 0
    Write-Progress -Activity "Processing 0/$($Tenants.Count)" -Status "0% completed" -PercentComplete 0
    $Tenants = Get-Tenants

    $Tenants | ForEach-Object {
        $Percent = [Math]::Floor($Completed / $Tenants.Count * 100)
        $Tenant = $_
        $Global:Tenant = $Tenant
        Write-Progress -Activity "Processing $($Tenant.DefaultDomainName) - $($Completed)/$($Tenants.Count)" -Status "$($Percent)% completed" -PercentComplete $Percent
        if ($Completed -gt 426) {
            try {

                Connect-CustomerExchange -CustomerTenantId $Tenant.CustomerId
    
                $AuditloggingEnabled = Get-AdminAuditLogConfig | Select-Object UnifiedAuditLogIngestionEnabled -ExpandProperty UnifiedAuditLogIngestionEnabled
    
                if ( $AuditloggingEnabled -eq $True) {
                    Write-Host "$($Tenant.DefaultDomainName) - AuditloggingEnabled: $AuditloggingEnabled"
                }
                else {
                    $OrgCust =  Enable-OrganizationCustomization
                    Set-AdminAuditLogConfig -UnifiedAuditLogIngestionEnabled $true
                    Write-Host "$($Tenant.DefaultDomainName) - AuditloggingEnabled: " -NoNewline
                    Write-Host "Enabled" -ForegroundColor Green
                }
    
            }
            catch {
            }
        }
        $Completed += 1
    }

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

Get-CustomerAuditlogging