我期待输出的结果
Get-Mailbox –Server MYserverName | Get-MailboxPermission | FL
为每个单独的邮箱input单独的文本文件,并为该邮箱命名文本文件 – 例如,我想拥有一个包含以下内容的文件夹:
每个包含邮箱权限结果。
我知道我可以做一个foreach循环:
ForEach-Object {Out-file $_.name}
来生成输出文件,但我不太确定如何做到这一步,以获得所有我的邮箱到个人文件的权限(我知道这会给我很多文本文件!)?
你几乎在那里。 像这样结合他们:
Get-Mailbox –Server MYserverName | % { Get-MailboxPermission $_ | FL | Out-file $_.name }
我在Exchange 2013实验室服务器上尝试了这一点,它似乎是做你所需要的。 对于这个function,2010年和2013年之间几乎没有什么区别。
如果你想在输出文件中使用“.txt”扩展名,请执行以下操作:
Get-Mailbox –Server MYserverName | % { Get-MailboxPermission $_ | FL | Out-file "$_.txt" }
感谢所有 – 这是非常接近的 – 但是当我在一些不同的2010服务器上运行它,我得到一个错误:
由于pipe道已经在执行,因此不执行pipe道。 pipe道不能同时执行。 + CategoryInfo:OperationStopped:(Microsoft.Power … tHelperRunspace:ExecutionCmdletHelperRunspace)[],PSInvalidOperationException + FullyQualifiedErrorId:RemotePipelineExecutionFailed
由于pipe道已经在执行,因此不执行pipe道。 pipe道不能同时执行。 + CategoryInfo:OperationStopped:(Microsoft.Power … tHelperRunspace:ExecutionCmdletHelperRunspace)[],PSInvalidOperationException + FullyQualifiedErrorId:RemotePipelineExecutionFailed
这导致我http://mikepfeiffer.net/2010/02/exchange-management-shell-error-pipelines-cannot-be-executed-concurrently/这build议我使用一个variables – 所以我最终的结果是:
$mailbox = Get-Mailbox $mailbox | % { Get-MailboxPermission $_ | FL | Out-file "$_.txt" }
哪个工作完美! 再次感谢!