Benutzer-Werkzeuge

Webseiten-Werkzeuge


exchange:postfaecher_mit_weiterleitung_nach_extern_ermitteln

Postfächer mit Weiterleitung ermitteln

Mit folgendem Script lassen sich alle Exchange-Postfächer ermitteln, die in den Nachrichtenübermittlungseinstellungen eine Weiterleitung eingetragen haben:

$MailboxesWithForwarding = get-mailbox -filter {forwardingAddress -ne $NULL}
foreach ($Mailbox in $MailboxesWithForwarding)
{
	$ext = "";
	$MailContact = $NULL;
	$MailContact = Get-MailContact -Identity $Mailbox.ForwardingAddress -erroraction 'silentlycontinue'
	if ($MailContact -ne $NULL)
	{
		$ext = $MailContact.ExternalEmailAddress.tostring()
	} else
	{
		$MailContact = get-mailbox -Identity $Mailbox.ForwardingAddress -erroraction 'silentlycontinue'
		if ($MailContact -eq $NULL)
		{
			$MailContact = get-dynamicdistributiongroup $Mailbox.ForwardingAddress -erroraction 'silentlycontinue'
			if ($MailContact -eq $NULL)
			{
				$MailContact = get-distributiongroup $Mailbox.ForwardingAddress
			}
		}
	}
	$ext = $MailContact.PrimarySMTPAddress.tostring()
	$Mailbox.PrimarySMTPAddress.tostring() + ";" + $Mailbox.LinkedMasterAccount + ";" + $ext
}

oder etwas einfacher:

Write-Host "Displayname;PrimarySmtpAddress;Forwardingaddress"
 
foreach ($MBox in get-mailbox -resultsize unlimited | ?{$_.Forwardingaddress -ne $null})
 
{
 
                try 
 
                {
 
                               $adresse = Get-Contact $MBox.forwardingaddress -Erroraction Stop; 
 
                               $adresse = $adresse.WindowsEmailAddress; 
 
                               Write-Host $MBox.displayname";"$MBox.Primarysmtpaddress";"$adresse
 
                } 
 
                catch 
 
                { 
 
                               $adresse = "Keine Weiterleitung nach Extern"
 
                }
 
}

exchange/postfaecher_mit_weiterleitung_nach_extern_ermitteln.txt · Zuletzt geändert: 2016/06/29 15:32 von ronny

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki