标签:不能 ati bug shel orm foreach 配额 not code
客户场景:为很多用户单独配置过邮箱配额,想重新规划,现需要导致所有用户实际容量清单
实现方式:直接上代码
#加载Exchange命令
Add-PSSnapin Microsoft.ex*
#主命令
[array]$output = "" | Select Name,ProhibitSendQuota,DBName
$DBs = Get-MailboxDatabase | Select Name,ProhibitSendQuota
foreach ($DB in $DBs) {
[string]$DBQuota = $DB.ProhibitSendQuota
[string]$DBName = $DB.Name
Write-Host "Database $DBName‘s quota is $DBQuota"
$Mails = Get-Mailbox -Database $DBName | Select Name,ProhibitSendQuota
foreach ($Mail in $Mails) {
if ($Mail.ProhibitSendQuota -eq "Unlimited") {
[string]$MailQuota = $DBQuota
}
else {
[string]$MailQuota = $Mail.ProhibitSendQuota
}
$Temp = "" | Select Name,ProhibitSendQuota,DBName
$Temp.Name = $Mail.Name
$Temp.ProhibitSendQuota = $MailQuota
$Temp.DBName = $DBName
#$Temp
$output += $Temp
}
}
$output | Export-Csv MailQuota.csv -NoTypeInformation -Encoding UTF8
输出结果:
与预期对比:
结论:如果为用户配置了不限制容量,则不能正常获取(客户实际环境中仅为董事长有配置无限制,手动修正,符合客户需求),欢迎帮解决此bug
标签:不能 ati bug shel orm foreach 配额 not code
原文地址:https://blog.51cto.com/duwei025/2411271