【发布时间】:2015-10-12 15:17:54
【问题描述】:
我正在尝试从多租户平台获取 Exchange 2010 报告。问题是我需要从不同的 cmdlet 获得的信息。 我们的客户要求 DisplayName、MailboxPlan、PrimarySMTPAddress (Get-Mailbox)、TotalItemSize 和 LastLogonTime (Get-MailboxStatistics)
我正在尝试使用 Powershell 执行此操作,但出现错误...您能帮我找出问题所在吗?
这是脚本:
$TBMailbox = Get-Mailbox -Organization organization -ResultSize Unlimited | Select-Object Identity,DisplayName,MailboxPlan,PrimarySMTPAddress
ForEach ($Mbx in $TBMailbox) {$temp += ,(Get-MailboxStatistics -Identity $Mbx.Identity | Select $Mbx.Identity,$Mbx.DisplayName,$Mbx.MailboxPlan,$Mbx.PrimarySMTPAddress,TotalItemSize,LastLogonTime)}
$temp | Export-Csv -Path "C:\Path"
我收到此错误:
- ForEach ($Mbx in $TBMailbox) {$temp += ,(Get-MailboxStatistics -Identity $Mbx.Identity | 选择
- CategoryInfo : InvalidArgument: (:) [Select-Object], NotSupportedException
- FullyQualifiedErrorId : DictionaryKeyUnknownType,Microsoft.PowerShell.Commands.SelectObjectCommand Select-Object : 无法将 Microsoft.Exchange.Data.Directory.ADObjectId 转换为以下类型之一 {System.String, System. Management.Automation.ScriptBlock}。在 line:1 char:96
有什么想法吗?
更新
尝试了不同的方法,但结果相同。我认为这里的问题是 Select-Object:
Get-Mailbox -Organization organization -ResultSize Unlimited | ForEach-Object -Process {Select-Object $_.DisplayName,$_.MailboxPlan,$_.PrimarySMTPAddress,@{n=”Size(MB)”;e = {$MBXstat = Get-MailboxStatistics -Identity $_.Identity; $MBXstat.totalItemsize.value.toMB()}},@{n="LastLogonTime";e = {$MBXstat = Get-MailboxStatistics -Identity $_.Identity; $MBXstat.lastlogontime}}} | Export-Csv "C:\report.csv"
【问题讨论】:
-
更新:我尝试使用
Select和Select-Object -Property,但失败并显示相同的错误消息
标签: powershell multi-tenant exchange-server-2010