In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Customer scenario: mailbox quotas have been configured separately for many users. If you want to replan, you now need to lead to the implementation of the actual capacity list of all users: code directly.
# load Exchange command
Add-PSSnapin Microsoft.ex*
# main command
[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
Output result:
In contrast to expectations:
Conclusion: if the user is configured with unlimited capacity, it can not be obtained normally (in the actual customer environment, only the chairman has unlimited configuration, manual correction, in line with customer needs), welcome to help solve this bug
Update: the customer raised several questions: 1. As a result, I can't see which users have manually configured 2. I don't know how much users use or how much space they use. The last login time is required. I have a lot of Mail Server, what if I only want to get one? 5. I opened this script on disk C, but the actual location of the script is on disk D. what if the output file is output to disk C? Need to output to the directory where the script is located
For the above, the script is optimized:
Go directly to the script first.
Param ($Server)
$outfile = $(Split-Path-Parent $MyInvocation.MyCommand.Definition) + "\" + (Get-Date-UFormat "% Y-%m-%d_%H-%M-%S") + ".csv"
Write-Host $outfile
[array] $output = "" | Select Name,DBName,UserQuota,DBQuota,ProhibitSendQuota,TotalItemSize,Use,LastLogonTime
# Select Name,DBName,UserQuota,DBQuota,ProhibitSendQuota,TotalItemSize,Use
Add-PSSnapin Microsoft.ex
If ($Server) {
$DBs = Get-MailboxDatabase-Server $Server | Select Name,ProhibitSendQuota
} else {
$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-ResultSize unlimited | Select SamaccountName,ProhibitSendQuota
Foreach ($Mail in $Mails) {
If ($Mail.ProhibitSendQuota-eq "Unlimited") {
[string] $MailQuota = $DBQuota
}
Else {
[string] $MailQuota = $Mail.ProhibitSendQuota
}
$TotalItemSize = Get-MailboxStatistics-Identity $Mail.SamaccountName | select TotalItemSize,LastLogonTime
$TempA = $Mail.ProhibitSendQuota
$Temp = "" | Select Name,DBName,UserQuota,DBQuota,ProhibitSendQuota,TotalItemSize,Use,LastLogonTime
$Temp.Name = $Mail.SamaccountName
$Temp.DBName = $DBName
If ($TempA-eq "Unlimited") {
$Temp.UserQuota = $TempA
} else {
# $Temp.UserQuota = $TempA.replace ("", "). Split (" (") [0]
$Temp.UserQuota = $($TempA-replace ""). Split ("(") [0]
}
$Temp.DBquota = $($DBQuota-replace ""). Split ("(") [0]
$Temp.ProhibitSendQuota = $($MailQuota-replace ""). Split ("(") [0]
$Temp.TotalItemSize = $($TotalItemSize.TotalItemSize-replace ""). Split ("(") [0]
$Temp.Use = ('{0:n2}'- f $($Temp.TotalItemSize / $Temp.ProhibitSendQuota 100)) +'%'
$Temp.LastLogonTime = $TotalItemSize.LastLogonTime
# $Temp
$output + = $Temp
}
}
# $output [1..$ output.count]
$output [1. $output.count] | Export-Csv $outfile-NoTypeInformation-Encoding UTF8-Force
Output result
Script scanning mode
a. If you execute directly, you get all users.
B.\ xxx.ps1-Server XX gets the DB on the specified Server
Welcome to add
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.