Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Email exchange 2007获取邮箱大小并发出警告配额_Email_Powershell_Exchange Server - Fatal编程技术网

Email exchange 2007获取邮箱大小并发出警告配额

Email exchange 2007获取邮箱大小并发出警告配额,email,powershell,exchange-server,Email,Powershell,Exchange Server,我有Exchange 2007,我在文本文件中得到一个用户列表,我需要得到一个如下表: 显示名称\邮箱大小(MB)\发出警告配额(MB) 用户1\25\40 我写了这样几句话: 添加PSSnapin-名称Microsoft.Exchange.Management.PowerShell.Admin $file=获取内容c:\mail.txt foreach($文件中的邮件){ Get-MailboxStatistics-Identity$mail | Sort-Property DisplayNa

我有Exchange 2007,我在文本文件中得到一个用户列表,我需要得到一个如下表:

显示名称\邮箱大小(MB)\发出警告配额(MB)

用户1\25\40

我写了这样几句话:

添加PSSnapin-名称Microsoft.Exchange.Management.PowerShell.Admin

$file=获取内容c:\mail.txt

foreach($文件中的邮件){

Get-MailboxStatistics-Identity$mail | Sort-Property DisplayName| ft-自动调整DisplayName的大小, @{expression={$\.totalitemsize.value.Thume()};label=“邮箱 大小(MB)“},|输出文件c:\mailboxes.txt-追加

}

1) 我知道我无法使用此命令获取“IssueWarningQuota”,我需要使用“get-
邮箱”,我不知道如何将其添加到输出文件中

2) 当我在输出文件中运行命令时,每个用户的头都是重复的, 我怎样才能避免呢

谢谢


Lior

您可以使用PSObject和导出Csv

Function ConvertStringSizeToInt64{   [CmdletBinding()]
[OutputType([Int64])]
Param ([Parameter(
        Mandatory=$true, 
        Position=0)]
[ValidateNotNull()]
[ValidateNotNullOrEmpty()]
[string]
$InString
)
Begin
{[Int64]$return = 0}
process 
{   [string]$OutSize = ""
    $InString | Select-String -AllMatches '((?<=\()\d{1,3}|(?<=\,)\d{1,3})' | 
    %{
        $OutSize = ($OutSize+$_.matches.value) -replace " ",""
        $OutSize = [System.Convert]::ToInt64($OutSize)
        $return = $OutSize
    }
}
end
{return $return}
}
# Create Templ Obect
$oT= New-Object psobject
$oT | Add-Member -MemberType NoteProperty -Name DisplayName -Value $null 
$oT | Add-Member -MemberType NoteProperty -Name MAilBoxSize -Value $null
$oT | Add-Member -MemberType NoteProperty -Name IssueWarningQuota -Value $null

Add-PSSnapin -Name Microsoft.Exchange.Management.PowerShell.Admin

$file=Get-Content c:\mail.txt
$R = @()
$file | %{
$T = $oT | select *
$M = Get-Mailbox $_
$T.DisplayName = $M.DisplayName
$T.MAilBoxSize = ConvertStringSizeToInt64 ((Get-MailboxStatistics -Identity $_).totalitemsize)
$T.IssueWarningQuota   =  If ($M.UseDatabaseQuotaDefaults) {ConvertStringSizeToInt64 (Get-MailboxDatabase $M.Database).IssueWarningQuota}
                          Else {ConvertStringSizeToInt64 $M.IssueWarningQuota}
$R +=$T
}
$R | Export-Csv c:\mail.csv
函数ConvertStringSizeToInt64{[CmdletBinding()]
[输出类型([Int64])]
Param([参数](
必填项=$true,
位置=0)]
[ValidateNotNull()]
[ValidateNotNullOrEmpty()]
[字符串]
$InString
)
开始
{[Int64]$return=0}
过程
{[string]$OutSize=“”
$InString |选择字符串-AllMatches'(?)?