Category Archives: Powershell

Finding unused accepted domains in Exchange 2013

If, for some reason, you want to see which domains in your exchange organisation are not being used (not registered in the ProxyAddresses fields of your users), use below snippet in the Exchange Powershell Module.

Note: this does NOT (yet) check for domains used in Public Folders or Mail Contacts.


$mailboxes = get-mailbox -Resultsize Unlimited
$groups = get-distributiongroup -Resultsize Unlimited
$domains = Get-AcceptedDomain
$output = @()

foreach ($domain in $domains){

 $obj = New-Object PSObject
 $obj | Add-Member NoteProperty domainName($domain.DomainName)
 $obj | Add-Member NoteProperty domainType($domain.DomainType)
 $res = $mailboxes | where-object {$_.EmailAddresses -Match $domain.DomainName}
 if(-not $res){
 $res = $groups | where-object {$_.EmailAddresses -Match $domain.DomainName}
 }
 if($res){
 $obj | Add-Member NoteProperty inUse("YES")
 }else{
 $obj | Add-Member NoteProperty inUse("NO")
 }
 $output += $obj
}

Write-Output $output

O365BulkDatacleaner released

The first public version of the O365BulkDatacleaner has been released.

This script is an addition to O365Datacleaner and will allow you to run the original script over many target locations simultaneously, using a CSV file as input.

This is the simplest and most reliable method currently available to make, for example, all the data on your fileservers spread out over homedirectories completely compliant with Onedrive for Business or Sharepoint Online’s requirements.