在对象上的PS Get-MailboxfolderStatistics过滤器

时间:2018-09-05 13:08:55

标签: windows powershell command office365

我需要将下面命令的特定结果通过管道传递给我可以在另一个命令中使用的变量。更具体地说,是 <VirtualHost *:443> ServerName support.nile.sd DocumentRoot /var/www/site SSLEngine on SSLCertificateFile /path/to/www_yoursite_com.crt SSLCertificateKeyFile /path/to/www_yoursite_com.key SSLCertificateChainFile /path/to/DigiCertCA.crt Redirect permanent / https://support.nile.sd/otrs/customer.pl </VirtualHost> 字段。是否有捷径可寻?我对folderpath cmdlet不熟悉。有人可以给我一个例子吗?

Where-Object

作为结果(以及更多):

Get-MailboxFolderStatistics $user1 -FolderScope Calendar

https://docs.microsoft.com/en-us/powershell/module/exchange/mailboxes/get-mailboxfolderstatistics?view=exchange-ps

2 个答案:

答案 0 :(得分:2)

   $folderPath = Get-MailboxFolderStatistics $user1 -FolderScope Calendar | Select-Object -ExpandProperty FolderPath

答案 1 :(得分:1)

您可以使用以下方式之一访问该属性:

(Get-MailboxFolderStatistics $user1 -FolderScope Calendar).FolderPath
# or
Get-MailboxFolderStatistics $user1 -FolderScope Calendar | Select-Object -ExpandProperty FolderPath

要分配给变量,只需添加分配:

$folder = (Get-MailboxFolderStatistics $user1 -FolderScope Calendar).FolderPath
# or
$folder = Get-MailboxFolderStatistics $user1 -FolderScope Calendar | Select-Object -ExpandProperty FolderPath

该变量可能是具有多个对象的数组。然后,您可以使用$folder[$i]访问其中的任何一个,其中$i是一个索引(从0开始)。如果您想要更通用的解决方案,可以使用以下命令强制将变量设置为数组:

[array]$folder = (Get-MailboxFolderStatistics $user1 -FolderScope Calendar).FolderPath
# or
[array]$folder = Get-MailboxFolderStatistics $user1 -FolderScope Calendar | Select-Object -ExpandProperty FolderPath