title: Automate exporting public folder to PST using Outlook 2016
body: <p>I'm searching for a way to automate using Outlook's Export to PST functionality in order to pull Public Folders named A-Z as individual PST files (because there is a PST size limit) and I'm hoping for a pure Powershell method.</p>
  
  <p>What I have found so far isn't automated but it helped when I had to get someone's folder copied over quickly.</p>
  
  <pre><code>Add-Type -assembly "Microsoft.Office.Interop.Outlook"
  $Outlook = New-Object -ComObject Outlook.Application
  $namespace = $Outlook.GetNameSpace("MAPI")
  
      #Get the public folder ID
       $SourceFolder = $namespace.PickFolder() | Select EntryID
  
  #Get the destination folder ID
      $DestinationFolder = $namespace.PickFolder() | Select EntryID
  
      $namespace.GetFolderFromID($SourceFolder).CopyTo($DestinationFolder)
  </code></pre>
  
  <p>The second post here <a href="https://serverfault.com/questions/180916/export-exchange-public-folder-to-pst-from-powershell">https://serverfault.com/questions/180916/export-exchange-public-folder-to-pst-from-powershell</a> looked helpful but I'm running into errors with the AutoDiscover URL and/or likely permission problems.</p>
  
  <p>Also found <a href="https://github.com/misterGF/DevOps-PowerShell/blob/master/export-PFdata.ps1" rel="nofollow noreferrer">this</a> which looked but I don't want PSTs attached to my outlook.</p>
  
  <p>Any pointers would be much appreciated!</p>