Learn Way to Convert OST to PST for Free using PowerShell Scripts

To convert OST to PST using a PowerShell Script, you must automate Microsoft Outlook because the OST format can only be accessed through Outlook’s MAPI interface. PowerShell will control Outlook to create a PST and copy mailbox folders into it.
Steps to convert the OST file to PST with PowerShell

Step 1 Open PowerShell

  1. Press Start
  2. Search PowerShell
  3. Click Run as Administrator

Step 2 Create the PowerShell script

Copy the following script and save it as:

# Start Outlook
$outlook = New-Object -ComObject Outlook.Application
$namespace = $outlook.GetNamespace("MAPI")
$namespace.Logon()

# PST file path
$pstPath = "C:\Temp\export.pst"

# Create PST store
$namespace.AddStore($pstPath)

# Get mailbox
$mailbox = $namespace.Folders.Item(1)

# Get new PST folder
$pstStore = $namespace.Folders | Where-Object {
    $_.Store.FilePath -eq $pstPath
}

# Copy folders
foreach ($folder in $mailbox.Folders) {
    $folder.CopyTo($pstStore)
}

Write-Host "OST exported to PST successfully"

Step 3 Allow script execution

Run Command

Set-ExecutionPolicy RemoteSigned

Step 4 Run the script
Now, navigate to the folder with script

cd C:\Scripts
.\convert-ost-pst.ps1

Step 5: Locate PST file

C:\Temp\export.pst

With the following this steps you can convert OST files to PST with PowerShell Script. But if the OST files is orphaned, inaccessible, corrupted, you utilize dedicated tools like Softaken OST to PST Converter Software.
With the use of this application you can easily convert OST files.
Steps

  1. Install and Run
  2. Browse and Add OST file
  3. Take Preview of OST file
  4. Choose PST file format
  5. Select desired location
  6. Start convert process

I hope you learn how to convert OST to PST with PowerShell.

However, PowerShell is not a practical option to convert OST to PST. It does not provide a direct way to recover or convert inaccessible OST files, and setting up custom scripts can be confusing. I checked it out first, but ended up using the TrustVare OST to PST Converter. No Outlook needed. Worked on my orphaned OST file and converted everything – emails and attachments – into a PST file in a few simple steps. This is a much better choice if you want something simpler and more dependable.