The Inbox Repair Tool (scanpst.exe) included in Outlook 2016, specifically Outlook 2016 for O365 version 1807 (build 16.0.10325.20082) and above now includes code that will allow you to run scanpst.exe from a command-line interface.
This functionality is great especially if you find yourself in a position where you need to scan and repair a large number of PSTs.
The following examples were tested on a PC running Windows 10 Enterprise (x64-bit) version 1803 (OS Build 17134.1039) with Outlook for Office 365 MSO (16.0.12026.20100) (32-bit) Version 1909 Click-to-Run.
The Inbox Repair Tool (scanpst.exe) is located within the installation directory for Office 2016. Change to the installation directory.
c:\Program Files (x86)\Microsoft Office\root\Office16
Here is an example of a one liner set to scan a .pst file named deleted4.pst.
scanpst.exe -force -silent -file "c:\test_psts\psts\deleted4.pst" -backupfile "c:\test_psts\psts\deleted4.bak" -log append
List of arguments along with their meanings
Batch file example
If you need to scan and repair a large number of .pst files, start out by piping and storing the .pst file names to a text file. We will use the output to build a batch file. Afterwards examine the list to ensure only .pst files are listed and remove any references to directories or sub-directories.
c:\test_psts>dir /s /b > c:\temp\pst_list.txt
Within the batch file simply repeat the command string from earlier while replacing the .pst file name for each of the .psts being processed. Save the file with a .bat extension.
scanpst.exe -force -silent -file "c:\test_psts\psts\deleted4.pst" -backupfile "c:\test_psts\psts\deleted4.bak" -log append scanpst.exe -force -silent -file "c:\test_psts\psts\deleted5.pst" -backupfile "c:\test_psts\psts\deleted5.bak" -log append scanpst.exe -force -silent -file "c:\test_psts\psts\deleted6.pst" -backupfile "c:\test_psts\psts\deleted6.bak" -log append
Change to the Office 2016 installation directory and run the batch file.
PowerShell script example
Better yet create a PowerShell script and handle iterating through each .pst through a foreach loop.
Generate the list of .pst files if you haven’t done so already. Afterwards examine the list to ensure only .pst files are listed and remove any references to directories or sub-directories.
c:\test_psts>dir /s /b > c:\temp\pst_list.txt
Open a PowerShell command line window and import the list of .psts storing them to a variable.
$psts = Get-Content -Path C:\temp\pst_list.txt
Change to the Office 2016 installation directory.
cd "C:\Program Files (x86)\Microsoft Office\root\Office16"
Run the foreach loop as depicted in the example below.
Foreach ($i in $psts) {.\scanpst.exe -force -silent -file "$i" -backupfile "$i.bak" -log append}
Here we can see that our process iterated through each of the .psts and generated a log file for each. One backup file was created since only one .pst was found to contain corruption.
Recent Comments