RSS

exchange2007 管理ps之查询cas服务器上邮箱大小

19 Jan

get-mailboxsizeMB.ps1

——

Function FunCASmail($strServer)
{
Get-MailboxStatistics -Server $strServer `
| Sort-Object -Property TotalItemSize `
| select-object  DisplayName, @{Name="Size (MB)"; Expression={ "{0:N2}" -f ($_.TotalItemSize/1.0MB)}}
}
$global:strEXserver = (get-mailboxserver).name
write-host "your exsit mailsever is "$strEXserver" "

if(!$args)
{ Write-Host -ForegroundColor green "you must supply an argument. Try getmailboxsizeMB.ps1 ?"}
ELSE
{
$strServer = "$args"
switch ($strServer)
{
"?"    { Write-Host "You must supply a server name `
Example: > Try getmailboxsizeMB.ps1 <servername>" -ForegroundColor green}
"all" { FunCASmail($global:strEXserver) }
"$strEXserver" { FunCASmail($strServer) }
Default { Write-Host "You must supply a real server name as "$strEXserver"" -ForegroundColor green }                     
}
}

 

——

这个代码,目前只适合单cas服务器环境。
使用这个.\get-mailboxsizeMB.ps1 <server> 即可获取你域内cas上的邮箱大小。
如果不带参数将返回一个提示
可以使用?
使用all参数可以查看所有cas服务器
如果你的参数是并非存在的服务器,那么将出现绿色的提示。

还是多cas环境没有测试该代码。如有人测试,请告知我。

Advertisements
 
Leave a comment

Posted by on January 19, 2009 in Exchange Server

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: