ANS Documentation

Improve This Doc
  • Cloud
  • Domains and DNS management
  • Backup and High Availability
  • eCommerce Stacks
  • Security
  • Email
  • Monitoring and usage management
  • Networking
  • Operating systems
    • Linux
    • VMware ESXi
    • Windows
      • Active Directory
      • Common Issues
      • Exchange
      • FTP
      • IIS
      • MSSQL
      • Networking
      • TLS 1.2 in PowerShell
      • RDP
      • Windows Server 2016
      • SSL/TLS and Schannel
      • Windows Administration
  • Webcelerator
  • MyUKFast
  • Home >
  • Operating systems >
  • Windows >
  • Exchange >
  • Exchange PowerShell Quick Commands

Exchange PowerShell Quick Commands¶

List all messages out from a specific domain within a specific time::

  Get-MessageTrackingLog -Server "servername" -EventID "SEND" -Start "27/07/2015 06:00:00" -End "27/07/2015 07:00:00" -ResultSize unlimited | where{$_.sender -like "*@contoso.com"}

Or you could output it to a text file::

  Get-MessageTrackingLog -Server "servername" -EventID "SEND" -Start "27/07/2015 06:00:00" -End "27/07/2015 07:00:00" -ResultSize unlimited | where{$_.sender -like "*@contoso.com"} | tee contoso.txt

List all of the distribution groups for a given domain::

  Get-DistributionGroup | where{$_.primarysmtpaddress -like "*@contoso.com"} | select name, primarysmtpaddress

List all members of that distribution group::

  Get-DistributionGroupMember -Identity "Name of Dist Group" | select -primarysmtpaddress

Set SCL rating of a domain and reject messages at the threshold::

  Get-Mailbox -OrganisationalUnit contoso.com | Set-Mailbox -SCLRejectEnabled $true -SCLRejectThreshold 5

List the size of a mailbox and the number of messages::

  $array = @()
  get-mailbox -identity *@contoso.com -resultsize unlimited | foreach-object {
  $dname=$_.DisplayName
  $email = $_.primarysmtpaddress
  $size=(Get-MailboxStatistics -identity $_).totalitemsize
  $count=(Get-MailboxStatistics -identity $_).itemcount
  $email = $email.Local + "@" + $email.Domain
  $object = New-Object -TypeName PSObject
  $object | Add-Member -Name 'Email' -MemberType Noteproperty -Value $email
  $object | Add-Member -Name 'Count' -MemberType Noteproperty -Value $count
  $object | Add-Member -Name 'Size' -MemberType Noteproperty -Value $size
  $array += $object

  }
  $array | export-csv C:\contoso.com.csv -notypeinformation

Next Article > Spam Confidence Level

  • Useful Links
  • SMB
  • Enterprise
  • Channel
  • Public Sector
  • ANS Data Centres
  • About ANS
  • Careers
  • Blog
  • Get in touch
  •  
  • Sales 0800 458 4545
  • Support 0800 230 0032
  • Get in touch

© ANS Group Limited | Terms and Conditions | Corporate Guidance | Sitemap
ANS Group Limited, registered in England and Wales, company registration number 03176761, registered office 1 Archway, Birley Fields, Manchester M15 5QJ