Schlagwort-Archive: domains

Used maildomain list

Report for all uses mail domains in Exchange mailbox address list with accepted domains and an example. Also helpful to find wrong entries 🙂

$acceptedDomains = $(Get-AcceptedDomain).DomainName
$aDomains = [String]::Join(„,@“,$acceptedDomains).Split(„,“)
$aDomains[0] = „@$($aDomains[0])“
$domains=@()
$domains.Clear()
$a = New-Object -TypeName psobject
$a | Add-Member Noteproperty Name „@myinternaldomain.local“
$a | Add-Member Noteproperty Count 0
$a | Add-Member Noteproperty Primary 0
$a | Add-Member Noteproperty Firstentry „“
$a | Add-Member Noteproperty FirstPrimary „“
$a | Add-Member Noteproperty AcceptedDomain „1“
$domains += $a
$x = Get-Mailbox -ResultSize Unlimited$y = $x.EmailAddresses | ?{$_ -like „*@*“}
foreach($z in $y){
$i = $z.IndexOf(„@“)
$d = $z.Substring($i).ToLower()
$isPrimary = $z.StartsWith(„SMTP:“)
if($domains.Name.Contains($d)){
$domains[$domains.Name.Indexof($d)].Count ++
}else{
$a = New-Object -TypeName psobject
$a | Add-Member Noteproperty Name $d
$a | Add-Member Noteproperty Count 1
$a | Add-Member Noteproperty Primary 0
$a | Add-Member Noteproperty Firstentry $z
$a | Add-Member Noteproperty FirstPrimary „“
if($aDomains.Contains($d)){
$a | Add-Member Noteproperty AcceptedDomain „1“
}else{
$a | Add-Member Noteproperty AcceptedDomain „0“
}
$domains += $a
}
if($isPrimary){
$domain = $domains[$domains.Name.Indexof($d)]
$domain.Primary ++
if($domain.FirstPrimary.Length -eq 0){$domain.FirstPrimary = $z}
}
}
$domains | Out-GridView