14
14
试试这个方法:
上面的内容对Outlook 2007没有起到作用。下面的方法应该是:
我用这个方法获得了成功的经验:
这里是我写的一个powershell脚本,它允许搜索一个文件夹名或列出完整的文件夹树。使用方法 :
没有参数,它将显示所有的文件夹
PS>.\get-MailboxFolders.ps1
└@conserver
└_Licences, codes etc.
└2 Clic
└Axter Ltd
└Chili
└Pérou
如果你传递一个参数,它将搜索包含该术语的文件夹名称,并输出路径
PS>.\get-MailboxFolders.ps1 201
The term *201* was found in :
\mailbox@domain.com015
\mailbox@domain.com\archivage010
\mailbox@domain.com\archivage011
,你可以使用邮箱参数搜索特定的账户
PS>.\get-MailboxFolders.ps1 -mailbox "infor"
Account selected = ENT, Service Informatique
└Archives
└Boîte de réception
,以下是脚本:
<#
.Synopsis
search outlook folders or display the folders tree
.Description
This script uses the outlook COM object.
.Parameter folder
Part of the folder's name to search for. If this parameter is not set the script will output
the complete folders tree
#>
[CmdletBinding()]
param(
[Parameter(Position=0, Mandatory=$false,ValueFromPipeline = $true)]
[System.String]
$folder=$null,
[Parameter(Position=1, Mandatory=$false)]
[System.String]
$mailbox=$null
)
$output=""
$find=@()
function Get-MailboxFolder($folder,$prefix, $search=$null, $firstrun=$false){
if(($search -ne $null) -and ($folder.name -match $search)) {
$script:find+=$folder.folderpath # if foldername match search term add it to the result
}
if($firstrun -eq $true){$script:output=$script:output+"$prefix$($_.name)`n"} # top level directories
if ($folder.folders.count -gt 0 ){ # If there are subfolders
if($firstrun -eq $false){
$script:output=$script:output+"$prefix$($folder.name)`n"
}
$prefix=" "+$prefix # preffix padding
$folder.folders |sort -property name| %{ get-MailboxFolder $_ $prefix $search} #recursivity
}
# No subfolder
if($folder.folders.count -eq 0 -and $firstrun -eq $false){$script:output=$script:output+"$prefix$($folder.name)`n"}
}
# Start outlook
$o=New-Object -ComObject outlook.application
$ns=$o.GetNamespace("MAPI")
if($mailbox -ne $null){
$bal=$ns.Folders |?{$_.name -match $mailbox}
}
else{
$bal=$ns.Folders.Item(1) # select the default mail account // you can let $bal=$ns.Folders to search through all accounts
}
write-host "Account selected = $($bal.name)"
$prefix="└"
$i=1
$bal.folders|sort -property name |%{
$percent=$i*100/($bal.folders.count)
write-progress -activity "Searching, please wait" -currentoperation "$($_.name)" -percentcomplete $percent
get-MailboxFolder $_ $prefix $folder $true
$i++
}
if(($folder -ne $null) -and ($folder -ne "")){ # are we searching ?
if ($find.count -eq 0){write-host "No folder *$folder* could be found"}
else{write-host "The term *$folder* was found in : ";$find}
}
else{$script:output} # display tree
$o.quit()
微软没有提供工具,所以我写了一个。免费的,这里没有任何漏洞: 如何搜索Outlook文件夹名称
如果你可以在 exchange 服务器上访问 powershell,你可以运行以下脚本来转储 exchange 系统中的所有文件夹 (由 https://blogs.msdn.microsoft.com/deva/2012/05/10/exchange-powershell-how-to-get-list-of-mailboxes-folders-subfolders-items-in-folder-foldersize-programmatically/ 提供):
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.* -erroraction SilentlyContinue
$saveto = $env:USERPROFILE + "\OutlookFolderList.csv"
Get-Mailbox | Select-Object alias | foreach-object {Get-MailboxFolderStatistics -Identity $_.alias | select-object Identity, ItemsInFolder, FolderSize} | Export-csv $saveto -NoTypeInformation
如果你想获得特定用户的信息,你可以使用这样的方法:
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.* -erroraction SilentlyContinue
$who = $args[0]
$saveto = $env:USERPROFILE + "\OutlookFolderListFor$who.csv"
Get-MailboxFolderStatistics -Identity $who | select-object Identity, ItemsInFolder, FolderSize | Export-csv $saveto -NoTypeInformation
这些方法可以创建 CSV 文件,可以很容易地在电子表格中打开并搜索。