How to configure the size limit for both (.pst) and (.ost) files in Outlook 2013 (PowerShell)

Introduction

This PowerShell script sample shows how to configure the size limit for both (.pst) and (.ost) files in Outlook 2013.

Scenarios

In Outlook, as the recommended PST file size is less than 2GB, some users want to increase thier Outlook achive files size, but according to the MSKB 832925, the steps seems significantly complicated,  The script can help user configure the size limit for .pst and ost files in Outlook, it could save the tedious process.

Note

This script can help you how to modify the registry automatically. However, serious problems might occur if you modify the registry incorrectly. Therefore, make sure that you follow these steps carefully. For added protection, back up the registry before you modify it. Then, you can restore the registry if a problem occurs. For more information about how to back up and restore the registry, click the following article number to view the article in the Microsoft Knowledge Base: 322756 (How to back up and restore the registry in Windows)(http://support.microsoft.com/kb/322756/ )

Script

Step 1: Click Start, type powershell in the search box on the Start Menu, right-click the Windows PowerShell icon, and then click Run Windows PowerShell as administrator. If the User Account Control dialog box appears, confirm that the action it displays is what you want, and then click Continue.

Step2: Start the PowerShell Console with administrator. To run the script in the Windows PowerShell Console, type the one command< Script Path> at the Windows PowerShell Console.

For example, type C:\Script\ConfigureSizeLimitFilesInOutlook.ps1

This is shown in the following figure.

You should enter the number follow the prompts.

Here are some code snippets for your references.

PowerShell
Edit|Remove
If(Test-Path -Path "$KeyPath\PST"{ 
    $MaxFileSizeValue = (Get-ItemProperty -Path "$KeyPath\PST").MaxFileSize 
    $SettingSize = $MaxFileSize/1024 
    Try 
    { 
        If($MaxFileSizeValue -ne $null) 
        { 
            Set-ItemProperty -Path "$KeyPath\PST" -Name "MaxFileSize" -Value $Value 
            Write-Host "Setting the value of properties of MaxFileSize successfully. The current maximum file limit is $SettingSize(GB)." 
        } 
         
        If($MaxFileSizeValue -eq $null) 
        { 
            New-ItemProperty -Path "$KeyPath\PST" -Name "MaxFileSize" -PropertyType DWord -Force | Out-Null 
            Set-ItemProperty -Path "$KeyPath\PST" -Name "MaxFileSize" -Value $Value 
            Write-Host "Setting the value of properties of MaxFileSize successfully. The current maximum file limit is $SettingSize(GB)." 
        } 
    } 
    Catch 
    { 
        Write-Host "Setting the value of properties of MaxFileSize failed." -ForegroundColor Red 
    } 
}
Prerequisite

Windows PowerShell 2.0

Office 2013

Microsoft All-In-One Script Framework is an automation script sample library for IT Professionals. The key value that All-In-One Script Framework is trying to deliver is Scenario-Focused Script Samples driven by IT Pros' real-world pains and needs. The team is monitoring all TechNet forums, IT Pros' support calls to Microsoft, and script requests submitted to TechNet Script Repository. We collect frequently asked IT scenarios, and create script samples to automate the tasks and save some time for IT Pros. The team of All-In-One Script Framework sincerely hope that these customer-driven automation script samples can help our IT community in this script-centric move.