Thursday 27 October 2011

Replacing Mailbox Display Name with Simple Display Name

Set-RemoteDomain "Default" -UseSimpleDisplayName $true

Requires SP1 RU4

Useful Links

Detecting/Removing Lingering AD Objects
Moving Mailboxes Across Forests
How to Move a CCR Storage Group
Testing WMI with WBEMTEST

Moving Mailboxes Across Forests

  • $c = Get-Credential  <-- Enter your account for X domain
  • $t = Get-Credential  <-- Enter your account for Y domain
  • move-mailbox -TargetDatabase "servername\storage group\database" -Identity 'mailbox name' -GlobalCatalog servername -SourceForestGlobalCatalog servername -NTAccountOU "OU=XXXX,DC=domain,DC=com" -SourceForestCredential $c -TargetForestCredential $t
Make sure to transfer any X500 addresses over as well.

Friday 14 October 2011

Exchange 2007 - Bulk Create Groups


  • import-csv "C:\filename.csv" | % {New-DistributionGroup -Name $_.Groupname -DisplayName $_.Displayname -OrganizationalUnit "domain.local/groups/distribution" -SamAccountName $_.SamName -Type Distribution}
    • Make sure your spreadsheet columns match the names above so that:
      • Groupname = The name you want the distribution group to have in Exchange (NOT the display name!)
      • SamName = Specify the same name as the Group Name. It's for AD.
      • Displayname = The display name (the one that contains #)
  • import-csv "C:\filename.csv" | % {Set-DistributionGroup -identity $_.Groupname -EmailAddressPolicyEnabled $false -PrimarySmtpAddress $_.email -RequireSenderAuthenticationEnabled $false}
    • Make sure your spreadsheet columns match the names above so that:
      • Groupname = The name of the group you want to change
      • Email = The email address you want to specify (if different than default)
      • If no groups need their email address specified, then run this command instead:
        • import-csv "C:\filename.csv" | % {Set-DistributionGroup -identity $_.Groupname -RequireSenderAuthenticationEnabled $false}

Exchange 2007 - Clear Transaction Logs

  • Run NTBackup and start an incremental backup on the affected storage group immediately 
    • Check the amount of space remaining and how quickly the drive is filling up. If it looks like NTBackup won't be able to complete before the drive fills up (the DB's will dismount) then proceed to performing the step below. 
  • On the Active mailbox server, run the following command in Powershell - make sure to update the path below accordingly 
    • eseutil /MK "H:\database\Third Storage Group\E02.chk"
    • The output will have a Checkpoint entry that looks like this:
      Checkpoint: (0x35B88,80,0)
    • 35B88 is the last 5 characters of the last transaction log that is needed by the DB. So if there are logs older than this file (35B87, 35B86, etc...) then those logs have been committed by the Database and are no longer needed. Ensure that you sort the view in Explorer by modified, since sorting by Name will not sort them properly.
    • You can proceed to move those logs elsewhere to free up the space, and then run an Incremental Backup to purge the remaining logs.

Exchange 2007 - Message Tracking

Search by IP:
  • get-messagetrackinglog -ResultSize unlimited -Start "9/3/2010 12:00:00 AM" -End "9/5/2010 11:59:00 PM" | where {$_.ClientIP -eq "xxx.xxx.xxx.xxx"} | fl ClientIP
Search by sender
  • get-messagetrackinglog -Sender "email@domain.com" -EventID "SEND" -Server servername -Start "2011/08/01 12:00:00 AM" -End "2011/10/13 12:00:00 AM" -ResultSize Unlimited | where {[string]$_.recipients -like "*@*"} |select Sender,@{Name="Recipients";Expression={$_.recipients}},MessageSubject,MessageId,Timestamp,ConnectorId | export-csv C:\filename.csv

Exchange 2007 - Mailbox Statistics

  • This will output Mailbox Statistics for all users on Exchange2007 in MB.

    • Get-MailboxStatistics -Server Servername | Sort -Property DisplayName | ft DisplayName, @{expression={$_.totalitemsize.value.ToMB()};label="Mailbox Size(MB)"}, itemcount, lastlogontime, lastlogofftime,lastloggedonuseraccount 
  • Sort all mailboxes by size
    • get-mailbox | Get-MailboxStatistics | Select @{n="DisplayName";e={$_.DisplayName}}, StorageGroupName,@{e={$_.TotalDeletedItemSize.Value.ToMB()};n="TotalDeletedItemsSize(MB)"}, DeletedItemCount, @{e={$_.TotalItemSize.Value.ToMB()};n="TotalItemSize(MB)"}, ItemCount, StorageLimitStatus | Sort-Object "TotalItemSize(MB)" | ft

  • Sort all mailboxes by "StorageLimitStatus"
    • get-mailbox | Get-MailboxStatistics | where-object {$_.StorageLimitStatus -eq "NoChecking"} | Select @{n="DisplayName";e={$_.DisplayName}}, StorageGroupName,@{e={$_.TotalDeletedItemSize.Value.ToMB()};n="TotalDeletedItemsSize(MB)"}, DeletedItemCount, @{e={$_.TotalItemSize.Value.ToMB()};n="TotalItemSize(MB)"}, ItemCount, StorageLimitStatus | Sort-Object "TotalItemSize(MB)" | ft