Overview

In a somewhat recent shift from On-Prem Exchange to Office 365, one of our objectives included eliminating those troublesome PST files by either merging them into users' mailboxes or transforming them into shared mailboxes. My goal is to shed light on how we conducted a network discovery to identify these files. While we successfully utilized SCCM for local PST files, this post will focus on the method I used for network-wide discovery.

The Details

Prior to running the following PowerShell script, you will need to download the PSTCollectionTool.

After downloading, extract the tool to a directory of your choice, preferably on the network. Next, adjust the script below to match the location of the PSTCollectionTool. Also, update the file shares as required, adding as many as needed for the search. Ultimately, upon completion, you will have a clear indication for each server being searched, simplifying the identification of systems with PST files. The results will be saved into an Excel spreadsheet, showcasing the following outcomes.

Note: The account executing the discovery process needs appropriate permissions to access the file shares.



PowerShell Code
$Date = Get-Date -Format 'MMMdd_HHMMttss'

$FileShares = @(
    "\\example_server1\path1\folder",
    "\\example_server2\path2\folder"
)

## Generate New Folder for Scans with Current Date and Time

New-Item -Path "\\path\path\Network Scan Details\$Date" -ItemType Directory -Force

ForEach ($Share in $FileShares)
{
    ## Generate New Folder for Scans for Each File Share
    
    $ValidFolderName = $Share.Replace("\\", "").Replace("$", "").Replace("\", "_")
    New-Item -Path "\\path\path\$Date\$ValidFolderName" -ItemType Directory
    
    ## Perform Scan
    
    $LogPath = "\\path\path\Network Scan Details\$Date\$ValidFolderName\Log"
    $ConfigPath = "\\path\path\Network Scan Details\$Date\$ValidFolderName\Config"
    
    $cmdPath = "\\path\PSTCollectionTool\DataCollectorMaster\DataCollectorMaster.exe"
    $cmdArgList = @(
        "-DataSource", "PST",
        "-Mode", "Find"
        "-JobName", "$ValidFolderName"
        "-Locations", "$Share"
        "-LogLocation", "$LogPath"
        "-ConfigurationLocation", "$ConfigPath"
    )
    
    & $cmdPath $cmdArgList
}