【问题标题】:Automate exporting public folder to PST using Outlook 2016使用 Outlook 2016 自动将公用文件夹导出到 PST
【发布时间】:2018-12-28 00:12:09
【问题描述】:

我正在寻找一种使用 Outlook 的导出到 PST 功能自动化的方法,以便将名为 AZ 的公共文件夹拉为单独的 PST 文件(因为有 PST 大小限制),我希望有一个纯 Powershell 方法。

到目前为止,我发现的内容并不是自动化的,但当我不得不快速复制某人的文件夹时,它会有所帮助。

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)

https://serverfault.com/questions/180916/export-exchange-public-folder-to-pst-from-powershell 的第二个帖子看起来很有帮助,但我遇到了 AutoDiscover URL 错误和/或可能的权限问题。

还发现 this 看起来但我不想将 PST 附加到我的 Outlook 中。

任何指针将不胜感激!

【问题讨论】:

    标签: powershell automation exchange-server devops


    【解决方案1】:

    将 Exchange 本地公用文件夹复制到本地 Outlook PST 文件。 感谢:https://github.com/misterGF/DevOps-PowerShell/blob/master/export-PFdata.ps1 https://www.vistax64.com/threads/looping-through-outlook-folders-and-subfolders-returning-numberof-e-mails.249828/

    How to disconnect PST file from Outlook using Powershell?

    设法解决了这个问题并获得了一些功能,请自行承担使用风险。不执行错误处理。

    function Get-MailboxFolder($folder)
     {
        Begin{
            $Outlook = New-Object -ComObject Outlook.Application
            $namespace = $Outlook.GetNameSpace("MAPI")
        }
    
        Process{
            New-Item -Path 'E:\PST.archive\Full Backup\Enterprise West' -Name "$($folder.Name)" -ItemType Directory    
    
            foreach ($f in $folder.folders) {
    
            #Location of PST files
            $PSTPath = 'E:\PST.archive\Full Backup\Enterprise West' + '\' + "$($folder.Name)"
    
            $PSTName = $($f.name) + '.pst'
    
            $FullPST = $PSTPath + '\' + $PSTName
    
            $namespace.AddStore("$FullPST")
            $pstFolder = $namespace.Session.Folders.GetLast()
    
            "Start Public Folder copy to local PST"
            [void]$f.CopyTo($pstFolder)
    
            }
        }#End process block
    
        End{
            "Removing attached PSTs from Outlook"
            $RemPST = $Outlook.Session.Stores | Where DisplayName -EQ 'Outlook Data File'
    
            foreach ($pst in $RemPST){
            $Outlook.Session.RemoveStore($pst.GetRootFolder())
            }
        }#end End Block
    }
    
    $WestFolders = $Outlook.Session.Folders.Item('Public Folders - YourNameHERE!!!!!').folders.item('All Public Folders').Folders.Item('Level-1').folders.item('Level-2').folders.item('Level-3')
    
    Get-MailboxFolder $WestFolders
    

    【讨论】:

      【解决方案2】:

      没有将公用文件夹导出到 PST 的自动化方法:

      Export-Mailbox 命令不适用于公用文件夹。

      您可以使用:

      1) 使用 Outlook : 导入/导出向导

      2) 使用第三方工具

      【讨论】:

      • 感谢您的回复,但请参阅下面我发布的答案,了解我设法开始工作的代码。
      猜你喜欢
      • 2023-03-30
      • 1970-01-01
      • 2021-09-28
      • 2013-03-02
      • 2013-10-10
      • 1970-01-01
      • 1970-01-01
      • 2015-08-27
      • 1970-01-01
      相关资源
      最近更新 更多