Export Exchange public folder to PST from PowerShellThere a easy way to move/change a public folder structure exchange server 2007?How do I restore Exchange 2003 public folder into 2007?Complete Public Folder Migration from Exchange 2007 to Exchange 2010Exchange 2007 - Public Folder Permissionsexport mailbox data from a mailbox to a .pst file (Exchange 2007)Can I export mailbox contents from an Exchange 2007 server if I install Outlook 2010 x64 on the same server?Restore deleted exchange 2007 public folder from backup .edb fileDecomissioning Exchange 2003 - Public folder instances still showing on Exchange 2003 serverHow to export specific folders from Exchange Mailbox' online archive to PSThow to backup/export office 365 email to pst in exchange hybrid environment?

Anabelian geometry ~ higher category theory

Was this character’s old age look CGI or make-up?

Why does the headset man not get on the tractor?

Is there anything special about -1 (0xFFFFFFFF) regarding ADC?

Why is a set not a partition of itself?

Is it possible to create different colors in rocket exhaust?

Can a tourist shoot a gun in the USA?

Will a coyote attack my dog on a leash while I'm on a hiking trail?

German characters on US-International keyboard layout

Does Lawful Interception of 4G / the proposed 5G provide a back door for hackers as well?

Why did the metro bus stop at each railway crossing, despite no warning indicating a train was coming?

What is the name of this Middle English letter?

Why was Thor doubtful about his worthiness to Mjolnir?

Frame adjustment for engine

Conditional probability - sum of dice is even given that at least one is a five

Solubility in different pressure conditions

Does SQL Server allow (make visible) DDL inside a transaction to the transaction prior to commit?

What's tha name for when you write multiple voices on same staff? And are there any cons?

How does emacs `shell-mode` know to prompt for sudo?

What to do if SUS scores contradict qualitative feedback?

Why do the lights go out when someone enters the dining room on this ship?

What information do scammers need to withdraw money from an account?

using `is` operator with value type tuples gives error

Is this a security concern for ubuntu users?



Export Exchange public folder to PST from PowerShell


There a easy way to move/change a public folder structure exchange server 2007?How do I restore Exchange 2003 public folder into 2007?Complete Public Folder Migration from Exchange 2007 to Exchange 2010Exchange 2007 - Public Folder Permissionsexport mailbox data from a mailbox to a .pst file (Exchange 2007)Can I export mailbox contents from an Exchange 2007 server if I install Outlook 2010 x64 on the same server?Restore deleted exchange 2007 public folder from backup .edb fileDecomissioning Exchange 2003 - Public folder instances still showing on Exchange 2003 serverHow to export specific folders from Exchange Mailbox' online archive to PSThow to backup/export office 365 email to pst in exchange hybrid environment?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








2















Is there a PowerShell cmdlet to export the contents of the public folder from Exchange 2007 into a PST on the network? I've got about 100 public folders that need archiving to different places on the network and would like to automate the process.



Also then need to be able to delete the public folder.



If not PowerShell, are there other utilities that can do the same from the command line?



Thanks, Rob.










share|improve this question






























    2















    Is there a PowerShell cmdlet to export the contents of the public folder from Exchange 2007 into a PST on the network? I've got about 100 public folders that need archiving to different places on the network and would like to automate the process.



    Also then need to be able to delete the public folder.



    If not PowerShell, are there other utilities that can do the same from the command line?



    Thanks, Rob.










    share|improve this question


























      2












      2








      2


      1






      Is there a PowerShell cmdlet to export the contents of the public folder from Exchange 2007 into a PST on the network? I've got about 100 public folders that need archiving to different places on the network and would like to automate the process.



      Also then need to be able to delete the public folder.



      If not PowerShell, are there other utilities that can do the same from the command line?



      Thanks, Rob.










      share|improve this question
















      Is there a PowerShell cmdlet to export the contents of the public folder from Exchange 2007 into a PST on the network? I've got about 100 public folders that need archiving to different places on the network and would like to automate the process.



      Also then need to be able to delete the public folder.



      If not PowerShell, are there other utilities that can do the same from the command line?



      Thanks, Rob.







      exchange-2007 powershell






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Sep 14 '10 at 11:34









      dunxd

      7,1111973113




      7,1111973113










      asked Sep 14 '10 at 10:59









      Rob NicholsonRob Nicholson

      84361946




      84361946




















          2 Answers
          2






          active

          oldest

          votes


















          2














          I believe that without 3rd party tools, you'll need to use Outlook to export the public folders.






          share|improve this answer






























            4














            Even five years on I couldn't find any examples of how to do this, so I used Glen Scales' excellent EWS & PowerShell blog posts to cobble this together. It's tweaked for Exchange 2013 SP1, but the functionality is pretty basic so it should work on earlier versions too.



            Script to export old Public Folders to a share on the filesystem



            #Needs to run an account with PublishingAuthor rights to the PFs
            #
            # Kev Maitland 08/09/15

            $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://yourMailServer.yourDomain.local/PowerShell/ -Authentication Kerberos
            Import-PSSession $Session -AllowClobber

            $EWSServicePath = '\yourMailServerC$Program FilesMicrosoftExchangeWeb Services2.2Microsoft.Exchange.WebServices.dll'
            Import-Module $EWSServicePath

            #If necessary, grant Owner permissions to each folder the Public Folder hierarchy to ensure we export everything
            #Get-PublicFolder -Identity "" -Recurse | Add-PublicFolderClientPermission -AccessRights Owner -User "yourDomainHighlyPriveligedAccount"


            #Set some variables
            $ExchVer = [Microsoft.Exchange.WebServices.Data.ExchangeVersion]::Exchange2013_SP1
            $ewsUrl = "https://mail.yourDomain.co.uk/EWS/Exchange.asmx"
            $upnExtension = "yourDomain.local"
            $smtpServer = "yourMailServer.yourDomain.local"
            $pFRootPath = ""
            $outputPathRoot = "\HV05PF"

            #Prepare some functions
            function FolderIdFromPath From Glen Scales http://gsexdev.blogspot.co.uk/2013/08/public-folder-ews-how-to-rollup-part-1.html
            param ($FolderPath = "$( throw 'Folder Path is a mandatory Parameter' )")
            process
            ## Find and Bind to Folder based on Path
            #Define the path to search should be seperated with
            #Bind to the MSGFolder Root
            $folderId = new-object Microsoft.Exchange.WebServices.Data.FolderId([Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::PublicFoldersRoot)
            $tfTargetFolder = [Microsoft.Exchange.WebServices.Data.Folder]::Bind($service,$folderId)
            #Split the Search path into an array
            $fldArray = $FolderPath.Split("")
            #Loop through the Split Array and do a Search for each level of folder
            for ($lint = 1; $lint -lt $fldArray.Length; $lint++)
            #Perform search based on the displayname of each folder level
            $fvFolderView = new-object Microsoft.Exchange.WebServices.Data.FolderView(1)
            $SfSearchFilter = new-object Microsoft.Exchange.WebServices.Data.SearchFilter+IsEqualTo([Microsoft.Exchange.WebServices.Data.FolderSchema]::DisplayName,$fldArray[$lint])
            $findFolderResults = $service.FindFolders($tfTargetFolder.Id,$SfSearchFilter,$fvFolderView)
            if ($findFolderResults.TotalCount -gt 0)
            foreach($folder in $findFolderResults.Folders)
            $tfTargetFolder = $folder


            else
            "Error Folder Not Found"
            $tfTargetFolder = $null
            break


            if($tfTargetFolder -ne $null)
            return $tfTargetFolder.Id.UniqueId.ToString()



            function getPublicFolderViaEws([string]$publicFolderPath)
            $folderId = new-object Microsoft.Exchange.WebServices.Data.FolderId(FolderIdFromPath -FolderPath $publicFolderPath)
            [Microsoft.Exchange.WebServices.Data.Folder]::Bind($service,$folderId)


            #Get set up using the current user's security context
            $windowsIdentity = [System.Security.Principal.WindowsIdentity]::GetCurrent()
            $sidbind = "LDAP://<SID=" + $windowsIdentity.user.Value.ToString() + ">"
            $aceuser = [ADSI]$sidbind
            $service = New-Object Microsoft.Exchange.WebServices.Data.ExchangeService($exchver)
            $service.Url = $ewsUrl
            $service.AutodiscoverUrl($aceuser.mail.ToString())

            $propertySet = new-object Microsoft.Exchange.WebServices.Data.PropertySet([Microsoft.Exchange.WebServices.Data.BasePropertySet]::FirstClassProperties) #Get all the default properties of the items in the Public Folders
            $propertySet.Add([Microsoft.Exchange.WebServices.Data.ItemSchema]::MimeContent) #Add the MimeContent property too, so that we can send it directy to the filestream later



            foreach ($folderPS in Get-PublicFolder -Recurse)
            New-Item -Path "$outputPathRoot$($folderPS.ParentPath)$($folderPS.Name)" -ItemType Directory #Make a filesystem folder to match the Public Folder hierarchy
            $folderEws = getPublicFolderViaEws -publicFolderPath "$($folderPS.ParentPath)$($folderPS.Name)".Replace("\","") #Bodge the odd occasion where we end up with two backslashes in a folder name
            $itemView = New-Object Microsoft.Exchange.WebServices.Data.ItemView(10)
            $foundItems = $null
            do
            $foundItems = $service.FindItems($folderEws.Id,$itemView) #Get the first batch of objects in the current Public Folder
            [Void]$service.LoadPropertiesForItems($foundItems,$propertySet) #Load the properties we specified earlier
            $i = $null
            foreach($email in $foundItems.Items)",''))$i") #Remove all illegal filesystem characters from the subject of the e-mail. If the result already exists on the filesystem, add an incremented number until it is unique (so that we don't accidentally overwrite e-mail threads)
            $i++

            [System.IO.File]::WriteAllBytes("$outputPathRoot$($folderPS.ParentPath)$($folderPS.Name)$($email.Subject.Replace(":",'').Replace("/",'').Replace("",'').Replace("*",'').Replace("?",'').Replace("<",'').Replace(">",'').Replace("
            $itemView.Offset += $foundItems.Items.Count #Get ready to process the next batch of e-mails in the Public Folder

            while($foundItems.MoreAvailable -eq $true)






            share|improve this answer























              Your Answer








              StackExchange.ready(function()
              var channelOptions =
              tags: "".split(" "),
              id: "2"
              ;
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function()
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled)
              StackExchange.using("snippets", function()
              createEditor();
              );

              else
              createEditor();

              );

              function createEditor()
              StackExchange.prepareEditor(
              heartbeatType: 'answer',
              autoActivateHeartbeat: false,
              convertImagesToLinks: true,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: 10,
              bindNavPrevention: true,
              postfix: "",
              imageUploader:
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              ,
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              );



              );













              draft saved

              draft discarded


















              StackExchange.ready(
              function ()
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f180916%2fexport-exchange-public-folder-to-pst-from-powershell%23new-answer', 'question_page');

              );

              Post as a guest















              Required, but never shown

























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              2














              I believe that without 3rd party tools, you'll need to use Outlook to export the public folders.






              share|improve this answer



























                2














                I believe that without 3rd party tools, you'll need to use Outlook to export the public folders.






                share|improve this answer

























                  2












                  2








                  2







                  I believe that without 3rd party tools, you'll need to use Outlook to export the public folders.






                  share|improve this answer













                  I believe that without 3rd party tools, you'll need to use Outlook to export the public folders.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Sep 24 '10 at 23:32









                  James BJames B

                  362




                  362























                      4














                      Even five years on I couldn't find any examples of how to do this, so I used Glen Scales' excellent EWS & PowerShell blog posts to cobble this together. It's tweaked for Exchange 2013 SP1, but the functionality is pretty basic so it should work on earlier versions too.



                      Script to export old Public Folders to a share on the filesystem



                      #Needs to run an account with PublishingAuthor rights to the PFs
                      #
                      # Kev Maitland 08/09/15

                      $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://yourMailServer.yourDomain.local/PowerShell/ -Authentication Kerberos
                      Import-PSSession $Session -AllowClobber

                      $EWSServicePath = '\yourMailServerC$Program FilesMicrosoftExchangeWeb Services2.2Microsoft.Exchange.WebServices.dll'
                      Import-Module $EWSServicePath

                      #If necessary, grant Owner permissions to each folder the Public Folder hierarchy to ensure we export everything
                      #Get-PublicFolder -Identity "" -Recurse | Add-PublicFolderClientPermission -AccessRights Owner -User "yourDomainHighlyPriveligedAccount"


                      #Set some variables
                      $ExchVer = [Microsoft.Exchange.WebServices.Data.ExchangeVersion]::Exchange2013_SP1
                      $ewsUrl = "https://mail.yourDomain.co.uk/EWS/Exchange.asmx"
                      $upnExtension = "yourDomain.local"
                      $smtpServer = "yourMailServer.yourDomain.local"
                      $pFRootPath = ""
                      $outputPathRoot = "\HV05PF"

                      #Prepare some functions
                      function FolderIdFromPath From Glen Scales http://gsexdev.blogspot.co.uk/2013/08/public-folder-ews-how-to-rollup-part-1.html
                      param ($FolderPath = "$( throw 'Folder Path is a mandatory Parameter' )")
                      process
                      ## Find and Bind to Folder based on Path
                      #Define the path to search should be seperated with
                      #Bind to the MSGFolder Root
                      $folderId = new-object Microsoft.Exchange.WebServices.Data.FolderId([Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::PublicFoldersRoot)
                      $tfTargetFolder = [Microsoft.Exchange.WebServices.Data.Folder]::Bind($service,$folderId)
                      #Split the Search path into an array
                      $fldArray = $FolderPath.Split("")
                      #Loop through the Split Array and do a Search for each level of folder
                      for ($lint = 1; $lint -lt $fldArray.Length; $lint++)
                      #Perform search based on the displayname of each folder level
                      $fvFolderView = new-object Microsoft.Exchange.WebServices.Data.FolderView(1)
                      $SfSearchFilter = new-object Microsoft.Exchange.WebServices.Data.SearchFilter+IsEqualTo([Microsoft.Exchange.WebServices.Data.FolderSchema]::DisplayName,$fldArray[$lint])
                      $findFolderResults = $service.FindFolders($tfTargetFolder.Id,$SfSearchFilter,$fvFolderView)
                      if ($findFolderResults.TotalCount -gt 0)
                      foreach($folder in $findFolderResults.Folders)
                      $tfTargetFolder = $folder


                      else
                      "Error Folder Not Found"
                      $tfTargetFolder = $null
                      break


                      if($tfTargetFolder -ne $null)
                      return $tfTargetFolder.Id.UniqueId.ToString()



                      function getPublicFolderViaEws([string]$publicFolderPath)
                      $folderId = new-object Microsoft.Exchange.WebServices.Data.FolderId(FolderIdFromPath -FolderPath $publicFolderPath)
                      [Microsoft.Exchange.WebServices.Data.Folder]::Bind($service,$folderId)


                      #Get set up using the current user's security context
                      $windowsIdentity = [System.Security.Principal.WindowsIdentity]::GetCurrent()
                      $sidbind = "LDAP://<SID=" + $windowsIdentity.user.Value.ToString() + ">"
                      $aceuser = [ADSI]$sidbind
                      $service = New-Object Microsoft.Exchange.WebServices.Data.ExchangeService($exchver)
                      $service.Url = $ewsUrl
                      $service.AutodiscoverUrl($aceuser.mail.ToString())

                      $propertySet = new-object Microsoft.Exchange.WebServices.Data.PropertySet([Microsoft.Exchange.WebServices.Data.BasePropertySet]::FirstClassProperties) #Get all the default properties of the items in the Public Folders
                      $propertySet.Add([Microsoft.Exchange.WebServices.Data.ItemSchema]::MimeContent) #Add the MimeContent property too, so that we can send it directy to the filestream later



                      foreach ($folderPS in Get-PublicFolder -Recurse)
                      New-Item -Path "$outputPathRoot$($folderPS.ParentPath)$($folderPS.Name)" -ItemType Directory #Make a filesystem folder to match the Public Folder hierarchy
                      $folderEws = getPublicFolderViaEws -publicFolderPath "$($folderPS.ParentPath)$($folderPS.Name)".Replace("\","") #Bodge the odd occasion where we end up with two backslashes in a folder name
                      $itemView = New-Object Microsoft.Exchange.WebServices.Data.ItemView(10)
                      $foundItems = $null
                      do
                      $foundItems = $service.FindItems($folderEws.Id,$itemView) #Get the first batch of objects in the current Public Folder
                      [Void]$service.LoadPropertiesForItems($foundItems,$propertySet) #Load the properties we specified earlier
                      $i = $null
                      foreach($email in $foundItems.Items)",''))$i") #Remove all illegal filesystem characters from the subject of the e-mail. If the result already exists on the filesystem, add an incremented number until it is unique (so that we don't accidentally overwrite e-mail threads)
                      $i++

                      [System.IO.File]::WriteAllBytes("$outputPathRoot$($folderPS.ParentPath)$($folderPS.Name)$($email.Subject.Replace(":",'').Replace("/",'').Replace("",'').Replace("*",'').Replace("?",'').Replace("<",'').Replace(">",'').Replace("
                      $itemView.Offset += $foundItems.Items.Count #Get ready to process the next batch of e-mails in the Public Folder

                      while($foundItems.MoreAvailable -eq $true)






                      share|improve this answer



























                        4














                        Even five years on I couldn't find any examples of how to do this, so I used Glen Scales' excellent EWS & PowerShell blog posts to cobble this together. It's tweaked for Exchange 2013 SP1, but the functionality is pretty basic so it should work on earlier versions too.



                        Script to export old Public Folders to a share on the filesystem



                        #Needs to run an account with PublishingAuthor rights to the PFs
                        #
                        # Kev Maitland 08/09/15

                        $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://yourMailServer.yourDomain.local/PowerShell/ -Authentication Kerberos
                        Import-PSSession $Session -AllowClobber

                        $EWSServicePath = '\yourMailServerC$Program FilesMicrosoftExchangeWeb Services2.2Microsoft.Exchange.WebServices.dll'
                        Import-Module $EWSServicePath

                        #If necessary, grant Owner permissions to each folder the Public Folder hierarchy to ensure we export everything
                        #Get-PublicFolder -Identity "" -Recurse | Add-PublicFolderClientPermission -AccessRights Owner -User "yourDomainHighlyPriveligedAccount"


                        #Set some variables
                        $ExchVer = [Microsoft.Exchange.WebServices.Data.ExchangeVersion]::Exchange2013_SP1
                        $ewsUrl = "https://mail.yourDomain.co.uk/EWS/Exchange.asmx"
                        $upnExtension = "yourDomain.local"
                        $smtpServer = "yourMailServer.yourDomain.local"
                        $pFRootPath = ""
                        $outputPathRoot = "\HV05PF"

                        #Prepare some functions
                        function FolderIdFromPath From Glen Scales http://gsexdev.blogspot.co.uk/2013/08/public-folder-ews-how-to-rollup-part-1.html
                        param ($FolderPath = "$( throw 'Folder Path is a mandatory Parameter' )")
                        process
                        ## Find and Bind to Folder based on Path
                        #Define the path to search should be seperated with
                        #Bind to the MSGFolder Root
                        $folderId = new-object Microsoft.Exchange.WebServices.Data.FolderId([Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::PublicFoldersRoot)
                        $tfTargetFolder = [Microsoft.Exchange.WebServices.Data.Folder]::Bind($service,$folderId)
                        #Split the Search path into an array
                        $fldArray = $FolderPath.Split("")
                        #Loop through the Split Array and do a Search for each level of folder
                        for ($lint = 1; $lint -lt $fldArray.Length; $lint++)
                        #Perform search based on the displayname of each folder level
                        $fvFolderView = new-object Microsoft.Exchange.WebServices.Data.FolderView(1)
                        $SfSearchFilter = new-object Microsoft.Exchange.WebServices.Data.SearchFilter+IsEqualTo([Microsoft.Exchange.WebServices.Data.FolderSchema]::DisplayName,$fldArray[$lint])
                        $findFolderResults = $service.FindFolders($tfTargetFolder.Id,$SfSearchFilter,$fvFolderView)
                        if ($findFolderResults.TotalCount -gt 0)
                        foreach($folder in $findFolderResults.Folders)
                        $tfTargetFolder = $folder


                        else
                        "Error Folder Not Found"
                        $tfTargetFolder = $null
                        break


                        if($tfTargetFolder -ne $null)
                        return $tfTargetFolder.Id.UniqueId.ToString()



                        function getPublicFolderViaEws([string]$publicFolderPath)
                        $folderId = new-object Microsoft.Exchange.WebServices.Data.FolderId(FolderIdFromPath -FolderPath $publicFolderPath)
                        [Microsoft.Exchange.WebServices.Data.Folder]::Bind($service,$folderId)


                        #Get set up using the current user's security context
                        $windowsIdentity = [System.Security.Principal.WindowsIdentity]::GetCurrent()
                        $sidbind = "LDAP://<SID=" + $windowsIdentity.user.Value.ToString() + ">"
                        $aceuser = [ADSI]$sidbind
                        $service = New-Object Microsoft.Exchange.WebServices.Data.ExchangeService($exchver)
                        $service.Url = $ewsUrl
                        $service.AutodiscoverUrl($aceuser.mail.ToString())

                        $propertySet = new-object Microsoft.Exchange.WebServices.Data.PropertySet([Microsoft.Exchange.WebServices.Data.BasePropertySet]::FirstClassProperties) #Get all the default properties of the items in the Public Folders
                        $propertySet.Add([Microsoft.Exchange.WebServices.Data.ItemSchema]::MimeContent) #Add the MimeContent property too, so that we can send it directy to the filestream later



                        foreach ($folderPS in Get-PublicFolder -Recurse)
                        New-Item -Path "$outputPathRoot$($folderPS.ParentPath)$($folderPS.Name)" -ItemType Directory #Make a filesystem folder to match the Public Folder hierarchy
                        $folderEws = getPublicFolderViaEws -publicFolderPath "$($folderPS.ParentPath)$($folderPS.Name)".Replace("\","") #Bodge the odd occasion where we end up with two backslashes in a folder name
                        $itemView = New-Object Microsoft.Exchange.WebServices.Data.ItemView(10)
                        $foundItems = $null
                        do
                        $foundItems = $service.FindItems($folderEws.Id,$itemView) #Get the first batch of objects in the current Public Folder
                        [Void]$service.LoadPropertiesForItems($foundItems,$propertySet) #Load the properties we specified earlier
                        $i = $null
                        foreach($email in $foundItems.Items)",''))$i") #Remove all illegal filesystem characters from the subject of the e-mail. If the result already exists on the filesystem, add an incremented number until it is unique (so that we don't accidentally overwrite e-mail threads)
                        $i++

                        [System.IO.File]::WriteAllBytes("$outputPathRoot$($folderPS.ParentPath)$($folderPS.Name)$($email.Subject.Replace(":",'').Replace("/",'').Replace("",'').Replace("*",'').Replace("?",'').Replace("<",'').Replace(">",'').Replace("
                        $itemView.Offset += $foundItems.Items.Count #Get ready to process the next batch of e-mails in the Public Folder

                        while($foundItems.MoreAvailable -eq $true)






                        share|improve this answer

























                          4












                          4








                          4







                          Even five years on I couldn't find any examples of how to do this, so I used Glen Scales' excellent EWS & PowerShell blog posts to cobble this together. It's tweaked for Exchange 2013 SP1, but the functionality is pretty basic so it should work on earlier versions too.



                          Script to export old Public Folders to a share on the filesystem



                          #Needs to run an account with PublishingAuthor rights to the PFs
                          #
                          # Kev Maitland 08/09/15

                          $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://yourMailServer.yourDomain.local/PowerShell/ -Authentication Kerberos
                          Import-PSSession $Session -AllowClobber

                          $EWSServicePath = '\yourMailServerC$Program FilesMicrosoftExchangeWeb Services2.2Microsoft.Exchange.WebServices.dll'
                          Import-Module $EWSServicePath

                          #If necessary, grant Owner permissions to each folder the Public Folder hierarchy to ensure we export everything
                          #Get-PublicFolder -Identity "" -Recurse | Add-PublicFolderClientPermission -AccessRights Owner -User "yourDomainHighlyPriveligedAccount"


                          #Set some variables
                          $ExchVer = [Microsoft.Exchange.WebServices.Data.ExchangeVersion]::Exchange2013_SP1
                          $ewsUrl = "https://mail.yourDomain.co.uk/EWS/Exchange.asmx"
                          $upnExtension = "yourDomain.local"
                          $smtpServer = "yourMailServer.yourDomain.local"
                          $pFRootPath = ""
                          $outputPathRoot = "\HV05PF"

                          #Prepare some functions
                          function FolderIdFromPath From Glen Scales http://gsexdev.blogspot.co.uk/2013/08/public-folder-ews-how-to-rollup-part-1.html
                          param ($FolderPath = "$( throw 'Folder Path is a mandatory Parameter' )")
                          process
                          ## Find and Bind to Folder based on Path
                          #Define the path to search should be seperated with
                          #Bind to the MSGFolder Root
                          $folderId = new-object Microsoft.Exchange.WebServices.Data.FolderId([Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::PublicFoldersRoot)
                          $tfTargetFolder = [Microsoft.Exchange.WebServices.Data.Folder]::Bind($service,$folderId)
                          #Split the Search path into an array
                          $fldArray = $FolderPath.Split("")
                          #Loop through the Split Array and do a Search for each level of folder
                          for ($lint = 1; $lint -lt $fldArray.Length; $lint++)
                          #Perform search based on the displayname of each folder level
                          $fvFolderView = new-object Microsoft.Exchange.WebServices.Data.FolderView(1)
                          $SfSearchFilter = new-object Microsoft.Exchange.WebServices.Data.SearchFilter+IsEqualTo([Microsoft.Exchange.WebServices.Data.FolderSchema]::DisplayName,$fldArray[$lint])
                          $findFolderResults = $service.FindFolders($tfTargetFolder.Id,$SfSearchFilter,$fvFolderView)
                          if ($findFolderResults.TotalCount -gt 0)
                          foreach($folder in $findFolderResults.Folders)
                          $tfTargetFolder = $folder


                          else
                          "Error Folder Not Found"
                          $tfTargetFolder = $null
                          break


                          if($tfTargetFolder -ne $null)
                          return $tfTargetFolder.Id.UniqueId.ToString()



                          function getPublicFolderViaEws([string]$publicFolderPath)
                          $folderId = new-object Microsoft.Exchange.WebServices.Data.FolderId(FolderIdFromPath -FolderPath $publicFolderPath)
                          [Microsoft.Exchange.WebServices.Data.Folder]::Bind($service,$folderId)


                          #Get set up using the current user's security context
                          $windowsIdentity = [System.Security.Principal.WindowsIdentity]::GetCurrent()
                          $sidbind = "LDAP://<SID=" + $windowsIdentity.user.Value.ToString() + ">"
                          $aceuser = [ADSI]$sidbind
                          $service = New-Object Microsoft.Exchange.WebServices.Data.ExchangeService($exchver)
                          $service.Url = $ewsUrl
                          $service.AutodiscoverUrl($aceuser.mail.ToString())

                          $propertySet = new-object Microsoft.Exchange.WebServices.Data.PropertySet([Microsoft.Exchange.WebServices.Data.BasePropertySet]::FirstClassProperties) #Get all the default properties of the items in the Public Folders
                          $propertySet.Add([Microsoft.Exchange.WebServices.Data.ItemSchema]::MimeContent) #Add the MimeContent property too, so that we can send it directy to the filestream later



                          foreach ($folderPS in Get-PublicFolder -Recurse)
                          New-Item -Path "$outputPathRoot$($folderPS.ParentPath)$($folderPS.Name)" -ItemType Directory #Make a filesystem folder to match the Public Folder hierarchy
                          $folderEws = getPublicFolderViaEws -publicFolderPath "$($folderPS.ParentPath)$($folderPS.Name)".Replace("\","") #Bodge the odd occasion where we end up with two backslashes in a folder name
                          $itemView = New-Object Microsoft.Exchange.WebServices.Data.ItemView(10)
                          $foundItems = $null
                          do
                          $foundItems = $service.FindItems($folderEws.Id,$itemView) #Get the first batch of objects in the current Public Folder
                          [Void]$service.LoadPropertiesForItems($foundItems,$propertySet) #Load the properties we specified earlier
                          $i = $null
                          foreach($email in $foundItems.Items)",''))$i") #Remove all illegal filesystem characters from the subject of the e-mail. If the result already exists on the filesystem, add an incremented number until it is unique (so that we don't accidentally overwrite e-mail threads)
                          $i++

                          [System.IO.File]::WriteAllBytes("$outputPathRoot$($folderPS.ParentPath)$($folderPS.Name)$($email.Subject.Replace(":",'').Replace("/",'').Replace("",'').Replace("*",'').Replace("?",'').Replace("<",'').Replace(">",'').Replace("
                          $itemView.Offset += $foundItems.Items.Count #Get ready to process the next batch of e-mails in the Public Folder

                          while($foundItems.MoreAvailable -eq $true)






                          share|improve this answer













                          Even five years on I couldn't find any examples of how to do this, so I used Glen Scales' excellent EWS & PowerShell blog posts to cobble this together. It's tweaked for Exchange 2013 SP1, but the functionality is pretty basic so it should work on earlier versions too.



                          Script to export old Public Folders to a share on the filesystem



                          #Needs to run an account with PublishingAuthor rights to the PFs
                          #
                          # Kev Maitland 08/09/15

                          $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://yourMailServer.yourDomain.local/PowerShell/ -Authentication Kerberos
                          Import-PSSession $Session -AllowClobber

                          $EWSServicePath = '\yourMailServerC$Program FilesMicrosoftExchangeWeb Services2.2Microsoft.Exchange.WebServices.dll'
                          Import-Module $EWSServicePath

                          #If necessary, grant Owner permissions to each folder the Public Folder hierarchy to ensure we export everything
                          #Get-PublicFolder -Identity "" -Recurse | Add-PublicFolderClientPermission -AccessRights Owner -User "yourDomainHighlyPriveligedAccount"


                          #Set some variables
                          $ExchVer = [Microsoft.Exchange.WebServices.Data.ExchangeVersion]::Exchange2013_SP1
                          $ewsUrl = "https://mail.yourDomain.co.uk/EWS/Exchange.asmx"
                          $upnExtension = "yourDomain.local"
                          $smtpServer = "yourMailServer.yourDomain.local"
                          $pFRootPath = ""
                          $outputPathRoot = "\HV05PF"

                          #Prepare some functions
                          function FolderIdFromPath From Glen Scales http://gsexdev.blogspot.co.uk/2013/08/public-folder-ews-how-to-rollup-part-1.html
                          param ($FolderPath = "$( throw 'Folder Path is a mandatory Parameter' )")
                          process
                          ## Find and Bind to Folder based on Path
                          #Define the path to search should be seperated with
                          #Bind to the MSGFolder Root
                          $folderId = new-object Microsoft.Exchange.WebServices.Data.FolderId([Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::PublicFoldersRoot)
                          $tfTargetFolder = [Microsoft.Exchange.WebServices.Data.Folder]::Bind($service,$folderId)
                          #Split the Search path into an array
                          $fldArray = $FolderPath.Split("")
                          #Loop through the Split Array and do a Search for each level of folder
                          for ($lint = 1; $lint -lt $fldArray.Length; $lint++)
                          #Perform search based on the displayname of each folder level
                          $fvFolderView = new-object Microsoft.Exchange.WebServices.Data.FolderView(1)
                          $SfSearchFilter = new-object Microsoft.Exchange.WebServices.Data.SearchFilter+IsEqualTo([Microsoft.Exchange.WebServices.Data.FolderSchema]::DisplayName,$fldArray[$lint])
                          $findFolderResults = $service.FindFolders($tfTargetFolder.Id,$SfSearchFilter,$fvFolderView)
                          if ($findFolderResults.TotalCount -gt 0)
                          foreach($folder in $findFolderResults.Folders)
                          $tfTargetFolder = $folder


                          else
                          "Error Folder Not Found"
                          $tfTargetFolder = $null
                          break


                          if($tfTargetFolder -ne $null)
                          return $tfTargetFolder.Id.UniqueId.ToString()



                          function getPublicFolderViaEws([string]$publicFolderPath)
                          $folderId = new-object Microsoft.Exchange.WebServices.Data.FolderId(FolderIdFromPath -FolderPath $publicFolderPath)
                          [Microsoft.Exchange.WebServices.Data.Folder]::Bind($service,$folderId)


                          #Get set up using the current user's security context
                          $windowsIdentity = [System.Security.Principal.WindowsIdentity]::GetCurrent()
                          $sidbind = "LDAP://<SID=" + $windowsIdentity.user.Value.ToString() + ">"
                          $aceuser = [ADSI]$sidbind
                          $service = New-Object Microsoft.Exchange.WebServices.Data.ExchangeService($exchver)
                          $service.Url = $ewsUrl
                          $service.AutodiscoverUrl($aceuser.mail.ToString())

                          $propertySet = new-object Microsoft.Exchange.WebServices.Data.PropertySet([Microsoft.Exchange.WebServices.Data.BasePropertySet]::FirstClassProperties) #Get all the default properties of the items in the Public Folders
                          $propertySet.Add([Microsoft.Exchange.WebServices.Data.ItemSchema]::MimeContent) #Add the MimeContent property too, so that we can send it directy to the filestream later



                          foreach ($folderPS in Get-PublicFolder -Recurse)
                          New-Item -Path "$outputPathRoot$($folderPS.ParentPath)$($folderPS.Name)" -ItemType Directory #Make a filesystem folder to match the Public Folder hierarchy
                          $folderEws = getPublicFolderViaEws -publicFolderPath "$($folderPS.ParentPath)$($folderPS.Name)".Replace("\","") #Bodge the odd occasion where we end up with two backslashes in a folder name
                          $itemView = New-Object Microsoft.Exchange.WebServices.Data.ItemView(10)
                          $foundItems = $null
                          do
                          $foundItems = $service.FindItems($folderEws.Id,$itemView) #Get the first batch of objects in the current Public Folder
                          [Void]$service.LoadPropertiesForItems($foundItems,$propertySet) #Load the properties we specified earlier
                          $i = $null
                          foreach($email in $foundItems.Items)",''))$i") #Remove all illegal filesystem characters from the subject of the e-mail. If the result already exists on the filesystem, add an incremented number until it is unique (so that we don't accidentally overwrite e-mail threads)
                          $i++

                          [System.IO.File]::WriteAllBytes("$outputPathRoot$($folderPS.ParentPath)$($folderPS.Name)$($email.Subject.Replace(":",'').Replace("/",'').Replace("",'').Replace("*",'').Replace("?",'').Replace("<",'').Replace(">",'').Replace("
                          $itemView.Offset += $foundItems.Items.Count #Get ready to process the next batch of e-mails in the Public Folder

                          while($foundItems.MoreAvailable -eq $true)







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Sep 14 '15 at 9:20









                          Kev MaitlandKev Maitland

                          412




                          412



























                              draft saved

                              draft discarded
















































                              Thanks for contributing an answer to Server Fault!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid


                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.

                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function ()
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f180916%2fexport-exchange-public-folder-to-pst-from-powershell%23new-answer', 'question_page');

                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              Club Baloncesto Breogán Índice Historia | Pavillón | Nome | O Breogán na cultura popular | Xogadores | Adestradores | Presidentes | Palmarés | Historial | Líderes | Notas | Véxase tamén | Menú de navegacióncbbreogan.galCadroGuía oficial da ACB 2009-10, páxina 201Guía oficial ACB 1992, páxina 183. Editorial DB.É de 6.500 espectadores sentados axeitándose á última normativa"Estudiantes Junior, entre as mellores canteiras"o orixinalHemeroteca El Mundo Deportivo, 16 setembro de 1970, páxina 12Historia do BreogánAlfredo Pérez, o último canoneiroHistoria C.B. BreogánHemeroteca de El Mundo DeportivoJimmy Wright, norteamericano do Breogán deixará Lugo por ameazas de morteResultados de Breogán en 1986-87Resultados de Breogán en 1990-91Ficha de Velimir Perasović en acb.comResultados de Breogán en 1994-95Breogán arrasa al Barça. "El Mundo Deportivo", 27 de setembro de 1999, páxina 58CB Breogán - FC BarcelonaA FEB invita a participar nunha nova Liga EuropeaCharlie Bell na prensa estatalMáximos anotadores 2005Tempada 2005-06 : Tódolos Xogadores da Xornada""Non quero pensar nunha man negra, mais pregúntome que está a pasar""o orixinalRaúl López, orgulloso dos xogadores, presume da boa saúde económica do BreogánJulio González confirma que cesa como presidente del BreogánHomenaxe a Lisardo GómezA tempada do rexurdimento celesteEntrevista a Lisardo GómezEl COB dinamita el Pazo para forzar el quinto (69-73)Cafés Candelas, patrocinador del CB Breogán"Suso Lázare, novo presidente do Breogán"o orixinalCafés Candelas Breogán firma el mayor triunfo de la historiaEl Breogán realizará 17 homenajes por su cincuenta aniversario"O Breogán honra ao seu fundador e primeiro presidente"o orixinalMiguel Giao recibiu a homenaxe do PazoHomenaxe aos primeiros gladiadores celestesO home que nos amosa como ver o Breo co corazónTita Franco será homenaxeada polos #50anosdeBreoJulio Vila recibirá unha homenaxe in memoriam polos #50anosdeBreo"O Breogán homenaxeará aos seus aboados máis veteráns"Pechada ovación a «Capi» Sanmartín e Ricardo «Corazón de González»Homenaxe por décadas de informaciónPaco García volve ao Pazo con motivo do 50 aniversario"Resultados y clasificaciones""O Cafés Candelas Breogán, campión da Copa Princesa""O Cafés Candelas Breogán, equipo ACB"C.B. Breogán"Proxecto social"o orixinal"Centros asociados"o orixinalFicha en imdb.comMario Camus trata la recuperación del amor en 'La vieja música', su última película"Páxina web oficial""Club Baloncesto Breogán""C. B. Breogán S.A.D."eehttp://www.fegaba.com

                              Vilaño, A Laracha Índice Patrimonio | Lugares e parroquias | Véxase tamén | Menú de navegación43°14′52″N 8°36′03″O / 43.24775, -8.60070

                              Cegueira Índice Epidemioloxía | Deficiencia visual | Tipos de cegueira | Principais causas de cegueira | Tratamento | Técnicas de adaptación e axudas | Vida dos cegos | Primeiros auxilios | Crenzas respecto das persoas cegas | Crenzas das persoas cegas | O neno deficiente visual | Aspectos psicolóxicos da cegueira | Notas | Véxase tamén | Menú de navegación54.054.154.436928256blindnessDicionario da Real Academia GalegaPortal das Palabras"International Standards: Visual Standards — Aspects and Ranges of Vision Loss with Emphasis on Population Surveys.""Visual impairment and blindness""Presentan un plan para previr a cegueira"o orixinalACCDV Associació Catalana de Cecs i Disminuïts Visuals - PMFTrachoma"Effect of gene therapy on visual function in Leber's congenital amaurosis"1844137110.1056/NEJMoa0802268Cans guía - os mellores amigos dos cegosArquivadoEscola de cans guía para cegos en Mortágua, PortugalArquivado"Tecnología para ciegos y deficientes visuales. Recopilación de recursos gratuitos en la Red""Colorino""‘COL.diesis’, escuchar los sonidos del color""COL.diesis: Transforming Colour into Melody and Implementing the Result in a Colour Sensor Device"o orixinal"Sistema de desarrollo de sinestesia color-sonido para invidentes utilizando un protocolo de audio""Enseñanza táctil - geometría y color. Juegos didácticos para niños ciegos y videntes""Sistema Constanz"L'ocupació laboral dels cecs a l'Estat espanyol està pràcticament equiparada a la de les persones amb visió, entrevista amb Pedro ZuritaONCE (Organización Nacional de Cegos de España)Prevención da cegueiraDescrición de deficiencias visuais (Disc@pnet)Braillín, un boneco atractivo para calquera neno, con ou sen discapacidade, que permite familiarizarse co sistema de escritura e lectura brailleAxudas Técnicas36838ID00897494007150-90057129528256DOID:1432HP:0000618D001766C10.597.751.941.162C97109C0155020