Exchange 2010 powershell 将 ProhibitSendQuota 设置为 ProhibitSendReceiveQuota

Exchange 2010 powershell 将 ProhibitSendQuota 设置为 ProhibitSendReceiveQuota

我需要将 Exchange 邮箱属性 ProhibitSendQuota 设置为与 ProhibitSendReceiveQuota 相等,但我的 powershell 失败,如下所示:

Get-Mailbox -Identity 'name.surname' | Set-Mailbox $_ -ProhibitSendQuota "$_.ProhibitSendReceiveQuota" -WhatIf

WARNING: The object has been corrupted, and it's in an inconsistent state. The following validation errors happened:
WARNING: The value of property 'ProhibitSendReceiveQuota' must be greater than or equal to that of property 'ProhibitSendQuota'. ProhibitSendReceiveQuota: '3.796 GB (4,075,520,000 bytes)', ProhibitSendQuota: '3.815 GB (4,096,000,000 bytes)'.

Cannot process argument transformation on parameter 'ProhibitSendQuota'. Cannot convert value ".ProhibitSendReceiveQuota" to type "Microsoft.Exchange.Data.Unlimited`1[Microsoft.Exchange.Data.ByteQuantifiedSize]". Error: "The string '.ProhibitSendReceiveQuota' isn't correctly formatted. It can contain a number with an optional unit specifier or the long ByteQuantifiedSize format. Examples include "12345", "104 MB", and "1 KB". Using the short format limits the string to 15 digits. However, the long format supports strings up to the maximum ByteQuantifiedSize value."
+ CategoryInfo          : InvalidData: (:) [Set-Mailbox], ParameterBindin...mationException
+ FullyQualifiedErrorId : ParameterArgumentTransformationError,Set-Mailbox

有什么建议吗?非常感谢您的帮助!

答案1

我建议尝试:

Get-Mailbox -Identity 'name.surname' | Set-Mailbox -ProhibitSendQuota ($_.ProhibitSendReceiveQuota) -WhatIf

几点说明:

-Set-mailbox 已经从管道接受一个对象,您不需要“$_”。

-"" 等于字符串。从错误中可以清楚地看到,PowerShell 不期望字符串值,因此会对其执行 barfs。在实际执行 CmdLet 之前,使用括号来评估括号内的表达式(就像数学一样!)

相关内容