Posted On February 27, 2021

PowerShell: Force Outlook to Compact On Exiting

kimconnect 0 comments
blog.KimConnect.com >> Windows >> PowerShell: Force Outlook to Compact On Exiting

Forcing Outlook to return free disk space to RDS nodes upon user exiting would be desirable to keep server storage in check. Also, deleted messages would be completely purged once this is set. Therefore, such feature would only be required on certain use-cases.

Please note that time it takes Outlook to shutdown will be increased. If Outlook is forced closed during the compaction process the data file could become corrupt. When using this registry key, one should not set the option to empty deleted items on exit as that would significantly expanding program closing lead-time.

# Force Outlook to compact pst upon closing
$officeRegKey=(get-childitem 'REGISTRY::HKEY_CURRENT_USER\Software\Microsoft\Office').Name|?{$_ -match '\d+\.\d+'}
$outlookRegKey="$officeRegKey\Outlook\PST"
$outlookCompactConfigKey='PSTNullFreeOnClose'
$outlookCompactConfigEnable=1
# set-itemproperty -Path $outlookRegKey -Name $outlookCompactConfigKey -Value $outlookCompactConfigEnable
[microsoft.win32.registry]::SetValue($outlookRegKey, $outlookCompactConfigKey, $outlookCompactConfigEnable)

Leave a Reply

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

Related Post

PowerShell: Manage Remote Desktop Servers by Logging Off Idle Sessions That Have Certain Inactive Programs

# manageRdsSessions.ps1 # Sequence of workflow: # a. Gather active and disconnected sessions on all…

How to set up Sip Trunk between two offices

1. Set up two Asterisk machines: Asterisk1 & Asterisk2   Example for Ubuntu: vim /etc/network/interfaces configure…

PowerShell: Get Connected Port by Process Name

# getProcessConnectionPort.ps1 $computerlist=@' SQL1 SQL2 '@ $computernames=@($computerList -split "`n")|%{$_.Trim()} $processname='sqlservr' $state='Established' $results=@() foreach ($computername in…