如何通过多个管道传递对象/值?

问题描述 投票:1回答:1

Get-Mailbox username让我举了例如用户的“Displayname”。 Get-MailboxRegionalConfiguration给了我更多信息。

我想用

PS> Get-Mailbox username | Get-MailboxRegionalConfiguration

Identity             Language        DateFormat TimeFormat TimeZone
--------             --------        ---------- ---------- --------
                     en-US           M/d/yyyy   h:mm tt    W. Europe Standard Time

我还需要来自DisplaynameGet-Mailbox。我可以用管子做这个吗?

到目前为止,我必须使用foreach并希望避免这种情况:

$MBs = Get-Mailbox -ResultSize Unlimited 

foreach ($MB in $MBs) { 
    $Name = $MB.DisplayName 
    $MRC = $MB | Get-MailboxRegionalConfiguration 
    $Lang = $MRC.Language 
    $DF = $MRC.DateFormat 
    $TF = $MRC.TimeFormat 
    $TZ = $MRC.TimeZone
}
powershell pipeline
1个回答
0
投票

您可以执行以下操作来扩展Get-MailboxRegionalConfiguration中的对象以及其他信息:

Get-Mailbox -ResultSize Unlimited | ForEach-Object {
    $name = $_.DisplayName
    $_ | Get-MailboxRegionalConfiguration |
        Select-Object *,@{n='DisplayName',e={$name}}
}
© www.soinside.com 2019 - 2024. All rights reserved.