As an Exchange admin, you will always come across mail stuck in a queue, there are so many reasons why this could happen but if you do need to export mail from a queue and not just simply delete it then you can do so running the following PowerShell command from the Exchange Management Shell (EMS) on your Exchange Server or remote computer.

  • Get-Message -Queue “HUBSRV01\XXXXXX” -ResultSize Unlimited | ForEach-Object {$Temp=”C:\Folder1\”+$_.InternetMessageID+”.eml”; $Temp=$Temp.Replace(“<“,”_”); $Temp=$Temp.Replace(“>”,”_”); Export-Message $_.Identity | AssembleMessage -Path $Temp}

Replace “HUBSRV01\XXXXXX” with the queue name on your server and “C:\Folder1” as shown above with your folder location.

You need to firstly suspend the messages in this queue or you will get an error when trying to export them.

Once you kick off the command above you can monitor the folder location you specified and you will see the messages in the folder.

Once done you can remove them and the queue will go back to 0 unless you have a bigger problem.

Hope it helps.

    wpChatIcon

    Discover more from Everything-PowerShell

    Subscribe now to keep reading and get access to the full archive.

    Continue reading