从Vb.net调用时,Get-MailboxStatistics不返回存档邮箱信息

时间:2019-09-09 18:27:42

标签: vb.net powershell

使用vb.net从应用程序内部获取邮箱列表以及与邮箱相关的一些详细信息。一切正常。尝试获取存档邮箱信息时,它的工作原理不同于脚本。

如果使用正确的配置从Powershell运行此脚本,则会获得存档邮箱详细信息:

Get-Mailbox useremail@domainname.com | Get-MailboxStatistics -Archive`

下面的代码(应该是等效的)没有给我存档邮箱。它提供了主邮箱。

我如何传递参数有问题吗?

Command = New System.Management.Automation.Runspaces.Command("Get-Mailbox")
Command.Parameters.Add("Identity", "useremail@domainname.com")
Pipeline.Commands.Add(Command)
Command = New System.Management.Automation.Runspaces.Command("Get-MailboxStatistics")
Command.Parameters.Add("Archive")
Pipeline.Commands.Add(Command)
Command = New System.Management.Automation.Runspaces.Command("Select-Object")
Command.Parameters.Add("Property", New String() {"MailboxGuid", "Database", "DisplayName", "TotalItemSize", "TotalDeletedItemSize", "ItemCount", "IsArchiveMailbox", "IsQuarantined"})
Pipeline.Commands.Add(Command)

PSObjects = Pipeline.Invoke()
Runspace.Dispose()

我想使用vb.net代码获取存档邮箱信息。

0 个答案:

没有答案