【发布时间】:2020-10-22 13:26:42
【问题描述】:
尝试设置查询 O365 Exchange、检查入站邮件、计算所有入站邮件、返回计数并对出站执行相同操作的 PS 脚本。
这是我目前所拥有的,它不断返回相同数量的入站和出站消息,即 500500。
除非它是预设的最大值并且我已达到上限,否则不确定如何实现。
# initialize session
$UserCredential = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
Import-PSSession $Session -DisableNameChecking
# O365 Inbound/Outbound tracking
$inbound = Get-MailTrafficReport -Direction Inbound | select "MessageCount"
$inbound -replace "[()\s+]"
$i = $inbound
$(for($i=0;$i -le 1000; $i+=1){$i} ) | ForEach-Object -begin {$inbound_sum=0 }-process {$inbound_sum+=$_}
$inbound_sum
# send sum to streaming dataset?
$outbound = Get-MailTrafficReport -Direction Outbound | select "MessageCount"
$outbound -replace "[()\s+]"
$o = $outbound
$(for($o=0;$o -le 1000; $o+=1){$o} ) | ForEach-Object -begin {$outbound_sum=0 }-process {$outbound_sum+=$_}
$outbound_sum
inbound_sum = outbound_sum?我在这里想念什么?
我尝试在迭代器行中取出$0 -le 1000,但它只是挂起。尽管如此,我怀疑将结果限制为 1000 是否会将入站和出站相加到完全相同的数字。
500 是 Windows 管理帐户 uid,好像我已经达到了管理限制。
【问题讨论】:
-
查看
Measure-Object -Sum
标签: powershell office365 exchangewebservices