skip to Main Content

Truncate Exchange logs with PowerShell

The Exchange logs disk is getting full, and you want to truncate Exchange logs without a backup. If you enable circular logging to clear Exchange database transaction logs, you have to unmount and mount the database before changes take effect. What if there is a way to remove Exchange database logs without unmounting and mounting the database? In this article, you will learn how to truncate Exchange database logs with PowerShell.


Before we start, it’s good to know that Exchange database logs should truncate when a backup is running. If it didn’t run properly, you have to troubleshoot and see what is going on. Sometimes you don’t have the time, and the disk is getting full, and you need a temporary fix to clear the Exchange database logs.

There are a couple of ways to do that:

  1. Enable circular logging, dismount database, mount database
  2. VSSTester PowerShell script

Both options will do the same in the end, that’s truncating the Exchange database logs. But, there is a significant difference in how they do it.

With option one, you have to unmount and mount the database, which leads to disruption to the users. If the mailbox database is big and there are terabytes of logs, this will take time. You have to do it after work hours unless you have a DAG and do a server switchover.

Option two will keep the database mounted. It means that the database will not go offline, and the users don’t get any disruptions. It will also create a snapshot of the database and logs volume.

Before running the script

At the moment, the mailbox database log volume shows that only 1,40 GB is free.

Truncate Exchange logs with PowerShell disk full

Prepare truncate Exchange logs PowerShell script

Download VSSTester.ps1 PowerShell script from GitHub or here (direct). At the moment of writing, the latest version is VSSTester 1.2. Save it on the Exchange Server. Create a scripts folder on the C: drive and place the script in C:\scripts.

Scripts folder

Truncate Exchange logs with PowerShell script

Start PowerShell as administrator and run VSSTester.ps1PowerShell script. The VSSTester script version 1.2 for Exchange 2010, 2013, 2016 shows.

After the script started, we do have two options. The one that we are looking for is option 1. Test backup using builtin Diskshadow.

Insert 1 and press Enter.

Specify a directory path, for example, C:\temp\ and press Enter.

It will verify the Exchange Server version and the VSS writer status. After that, it will check which mailbox databases are available and ask us which one to backup. In my example, we like to clear the logs of the mailbox database DB02, which is number 1. Type 1 and press Enter.

Check which drive is not in use. In our example, drive X: is not in use, and that’s what we will use. Enter X: and press Enter.

This time it asks for an unused drive letter for the log volume. We will use drive letter Y: because it’s not in use and press Enter.

Start File Explorer and have a look at the X: and Y: drives.

Truncate Exchange logs with PowerShell script snapshot

Select option 1 and press Enter to delete the snapshot.

Press Enter to exit the PowerShell script.

Verify Exchange database logs

Verify that the snapshots are removed and that the logs are cleared.

Truncate Exchange logs with PowerShell logs disk cleared

Open the database log volume and verify that Exchange database truncation is completed successfully.

Truncate Exchange logs with PowerShell check database logs

It’s looking great. Did this help you to truncate Exchange database logs without a backup?

Keep reading: Install FREE Let’s Encrypt certificate in Exchange Server ยป


You learned how to truncate Exchange database logs with PowerShell. The script is excellent if a high spike suddenly comes in, and the transaction logs are growing very fast. Or if the backup all of a sudden is not working.

Use the PowerShell script to clear Exchange database logs safely. The changes are applied immediately. There is no need to unmount and mount the database. That’s great because you will not disrupt any users.

Did you enjoy this article? You may also like Move Exchange 2016 database to another drive. Don’t forget to follow us and share this article.



ALI TAJRAN is a passionate IT Architect, IT Consultant, and Microsoft Certified Trainer. He started Information Technology at a very young age, and his goal is to teach and inspire others. Read more ยป

This Post Has One Comment

  1. Mooi en duidelijk artikel Ali!
    Ik kan me herinneren dat we dit ooit (2 jaar geleden?) handmatig moesten doen bij een klant van ons op de KG. De maildataschijven liepen vaak vol door niet getruncated exchange logs ๐Ÿ˜ฅ
    Dit had veel tijd gescheeld bij de oplossing doorvoeren (hadden we dit eerder geweten) ๐Ÿ˜‰
    Bij een volgende keer kunnen we de Powershell oplossing toepassen, scheelt weer tijd ๐Ÿ˜ƒ
    Groet, Cor

Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top