我有一个包含19个不同邮箱配额的用户的CSV文件,我希望能够为他们当前的邮箱大小增加200多个。如果我尝试设置邮箱,它将改变他们当前的大小,他们都将拥有相同的邮箱配额,我不想要!我只想添加200MB到他们当前的大小。
wait
查找邮箱配额脚本
$list = import-csv c:\list.csv
foreach ($user in $list) {set-mailbox -identity $user.user -UseDatabaseQuotaDefaults $false -IssueWarningQuota 200MB -ProhibitSendQuota 250MB -ProhibitSendReceiveQuota 280MB}
答案 0 :(得分:1)
您只需要将200MB
添加到foreach-loop中的当前配额值,以便新值对于循环中的每个用户都是唯一的。我不知道你的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
}