1 Pluspunkt 0 Minuspunkte

Ich habe dieses Script um alle Mailboxen abzufragen

# Füge den Exchange-Modul-Snapin hinzu
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.SnapIn

# Finde alle Postfächer mit zusätzlicher "domain.co.at" Adresse
$Mailboxes = Get-Mailbox -ResultSize Unlimited

$MailboxesWithAdditionalAddress = foreach ($Mailbox in $Mailboxes) {

    $AdditionalAddresses = $Mailbox.EmailAddresses | Where-Object { $_ -like "*@domain.co.at" }

    if ($AdditionalAddresses) {

        [PSCustomObject]@{
            Type = "Mailbox"
            DisplayName = $Mailbox.DisplayName
            PrimarySmtpAddress = $Mailbox.PrimarySmtpAddress
            AdditionalAddresses = $AdditionalAddresses -join ", "
        }

    }

}

Wie kann ich aber alle Verteilerlisten anzeigen die eine zusätzliche SMTP Adresse haben?

von  

1 Antwort

0 Pluspunkte 0 Minuspunkte

Statt Get-Mailbox musst du das Cmdlet Get-DistributionGroup verwenden.

# Finde alle Verteilergruppen mit zusätzlicher "domain.co.at" Adresse
$DistributionGroups = Get-DistributionGroup -ResultSize Unlimited

$DistributionGroupsWithAdditionalAddress = foreach ($DistributionGroup in $DistributionGroups) {

    $AdditionalAddresses = $DistributionGroup.EmailAddresses | Where-Object { $_ -like "*@domain.co.at" }

    if ($AdditionalAddresses) {

        [PSCustomObject]@{
            Type = "Distribution Group"
            DisplayName = $DistributionGroup.DisplayName
            PrimarySmtpAddress = $DistributionGroup.PrimarySmtpAddress
            AdditionalAddresses = $AdditionalAddresses -join ", "
        }

    }

}

von (732 Punkte)