问题描述
我正在尝试获取在特定日期范围内收到的公用文件夹中的邮件项目数以及最后一封邮件的日期。
$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 (将#修改为@)