Powershell 将 19 的邮箱大小增加 200MB Exchange 2007
Powershell Increase mailbox size for 19 by 200MB Exchange 2007
我有 19 个用户的 CSV 文件,他们的邮箱配额不同,我希望能够将他们当前的邮箱大小再增加 200mb。如果我尝试设置邮箱,它将更改它们当前的大小,并且它们都将具有相同的邮箱配额,这是我不想要的!!我只想在当前大小的基础上增加 200MB。
$list = import-csv c:\list.csv
foreach ($user in $list) {set-mailbox -identity $user.user -UseDatabaseQuotaDefaults $false -IssueWarningQuota 200MB -ProhibitSendQuota 250MB -ProhibitSendReceiveQuota 280MB}
查找邮箱配额脚本
$List = Import-Csv C:\temp\Users_size.csv
foreach ($user in $List){
Get-Mailbox $user.user_id | fl name, *Quota | Out-File -Append c:\size.csv
Get-MailboxStatistics $user.user_id | fl TotalItemSize | Out-File -Append c:\size.csv}
您只需将 200MB
添加到 foreach 循环内的当前配额值,这样新值对于循环中的每个用户都是唯一的。我不知道你的 csv 是什么样子,所以我创建了一个 sample-csv。
我没有 Exchange 环境,所以这些都是未经测试的代码
list.csv
User,IssueWarningQuota,ProhibitSendQuota,ProhibitSendReceiveQuota,SomeOtherColumns
User1,209715200,262144000,293601280,SomeOtherValue
User2,314572800,367001600,398458880,SomeOtherValue2
样本:
$list = Import-Csv -Path c:\list.csv
foreach ($user in $list) {
#Create variables with new quota-values for readability. Can be replaced with -IssueWarningQuoa ([int]$_.IssueWarningQuota + $AddQuota) -Prohi.... in the command itself.
#Values from CSV are string by default, so we need to cast the value to int before adding (unless it will append to string).
$IssueWarningQuota = [int]$_.IssueWarningQuota + 200MB
$ProhibitSendQuota = [int]$_.ProhibitSendQuota + 200MB
$ProhibitSendReceiveQuota = [int]$_.ProhibitSendReceiveQuota + 200MB
Set-mailbox -identity $user.user -UseDatabaseQuotaDefaults $false -IssueWarningQuota $IssueWarningQuota -ProhibitSendQuota $ProhibitSendQuota -ProhibitSendReceiveQuota $ProhibitSendReceiveQuota
}
如果您的 csv 不包含当前配额值,您可以使用 Get-MailBox
获取它们。
$list = Import-Csv -Path c:\list.csv
foreach ($user in $list) {
$mb = Get-Mailbox $user.user
$IssueWarningQuota = $mb.IssueWarningQuota + 200MB
$ProhibitSendQuota = $mb.ProhibitSendQuota + 200MB
$ProhibitSendReceiveQuota = $mb.ProhibitSendReceiveQuota + 200MB
Set-mailbox -identity $user.user -UseDatabaseQuotaDefaults $false -IssueWarningQuota $IssueWarningQuota -ProhibitSendQuota $ProhibitSendQuota -ProhibitSendReceiveQuota $ProhibitSendReceiveQuota
}
我有 19 个用户的 CSV 文件,他们的邮箱配额不同,我希望能够将他们当前的邮箱大小再增加 200mb。如果我尝试设置邮箱,它将更改它们当前的大小,并且它们都将具有相同的邮箱配额,这是我不想要的!!我只想在当前大小的基础上增加 200MB。
$list = import-csv c:\list.csv
foreach ($user in $list) {set-mailbox -identity $user.user -UseDatabaseQuotaDefaults $false -IssueWarningQuota 200MB -ProhibitSendQuota 250MB -ProhibitSendReceiveQuota 280MB}
查找邮箱配额脚本
$List = Import-Csv C:\temp\Users_size.csv
foreach ($user in $List){
Get-Mailbox $user.user_id | fl name, *Quota | Out-File -Append c:\size.csv
Get-MailboxStatistics $user.user_id | fl TotalItemSize | Out-File -Append c:\size.csv}
您只需将 200MB
添加到 foreach 循环内的当前配额值,这样新值对于循环中的每个用户都是唯一的。我不知道你的 csv 是什么样子,所以我创建了一个 sample-csv。
我没有 Exchange 环境,所以这些都是未经测试的代码
list.csv
User,IssueWarningQuota,ProhibitSendQuota,ProhibitSendReceiveQuota,SomeOtherColumns
User1,209715200,262144000,293601280,SomeOtherValue
User2,314572800,367001600,398458880,SomeOtherValue2
样本:
$list = Import-Csv -Path c:\list.csv
foreach ($user in $list) {
#Create variables with new quota-values for readability. Can be replaced with -IssueWarningQuoa ([int]$_.IssueWarningQuota + $AddQuota) -Prohi.... in the command itself.
#Values from CSV are string by default, so we need to cast the value to int before adding (unless it will append to string).
$IssueWarningQuota = [int]$_.IssueWarningQuota + 200MB
$ProhibitSendQuota = [int]$_.ProhibitSendQuota + 200MB
$ProhibitSendReceiveQuota = [int]$_.ProhibitSendReceiveQuota + 200MB
Set-mailbox -identity $user.user -UseDatabaseQuotaDefaults $false -IssueWarningQuota $IssueWarningQuota -ProhibitSendQuota $ProhibitSendQuota -ProhibitSendReceiveQuota $ProhibitSendReceiveQuota
}
如果您的 csv 不包含当前配额值,您可以使用 Get-MailBox
获取它们。
$list = Import-Csv -Path c:\list.csv
foreach ($user in $list) {
$mb = Get-Mailbox $user.user
$IssueWarningQuota = $mb.IssueWarningQuota + 200MB
$ProhibitSendQuota = $mb.ProhibitSendQuota + 200MB
$ProhibitSendReceiveQuota = $mb.ProhibitSendReceiveQuota + 200MB
Set-mailbox -identity $user.user -UseDatabaseQuotaDefaults $false -IssueWarningQuota $IssueWarningQuota -ProhibitSendQuota $ProhibitSendQuota -ProhibitSendReceiveQuota $ProhibitSendReceiveQuota
}