管道到 Exchange Online 中的 Get-Mailbox

Pipe to Get-Mailbox in Echange Online

在那种情况下必须使用 ForEach-Object 还是我可以将变量直接通过管道传递给 Get-Mailbox

$importuser = Import-Csv -Path C:\mymailbox.csv -OutVariable string
$importuser | ForEach-Object {
  get-mailbox -identity $_.Name|Select-Object primarysmtpaddress,whenMailboxCreated
} | ConvertTo-Csv -NoTypeInformation | Set-Content -Path "exportwhithedate"

由于 -Identity 采用管道输入(根据 the docs 和我的测试),您可以通过管道输入:

$importUser.name | Get-Mailbox # And so on