如何解决给定日期范围内公用文件夹中的邮件数
我正在尝试获取在特定日期范围内收到的公用文件夹中的邮件项目数以及最后一封邮件的日期。
$i=1
#Get the name of the public folder to search
$fName=Read-Host -Prompt 'Enter the name of the public folder:'
write-host "Retrieving selected public folder $fName and all subfolders this may take some time."
#Get all folders
$folders=Get-PublicFolder \$fName -recurse -resultsize unlimited
$folderCount = $folders.count
$pbf = @()
#Loop through folders,get required data and display progess bar
Foreach($folders in $folders){
$id=$folders.identity
Write-Progress -Activity "Processing folder $id" -Status "Folder $i of $folderCount" -PercentComplete (($i/$folderCount)*100)
$mailDetail=Get-PublicFolderItemStatistics -Identity $id | select PublicFolderName,CreationTime|sort-object CreationTime -Descending | Select-Object -First 1 |Where-Object{$_.CreationTime -gt [DateTime]::ParseExact('01/01/2019','dd/MM/yyyy',$Null) -and $_.CreationTime -lt [DateTime]::ParseExact('25/12/2020',$Null)}
$pbf+= $mailDetail
$i++;
}
$pbf | Export-Csv -Path $env:userprofile\desktop\"PublicFolderMailBox_$($fName.ToString())_LastMail_2019_2020_$((Get-Date).ToString("ddMMyyyy_HH%MM")).csv" -NoTypeinformation
有没有办法可以对项目数求和并将其添加到每个文件夹的数组中,我正在考虑添加另一个变量并执行获取 get-publicfolderstatistics 的 ItemCount 或 get- 中的组对象publicfolderitemstatistics,但我无法将其添加到数组中。
注意,我刚刚尝试获取特定日期范围内的所有邮件并输出它们,即不受接收到的最后一封邮件的限制,但是当我这样做时,邮件数量超过了 Excel 中的行数。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。