简体   繁体   English

Powershell,拆分列表Get-Mailbox EmailAddresses

[英]Powershell, split listing Get-Mailbox EmailAddresses

This is my Powershell command: 这是我的Powershell命令:

Get-Mailbox -Identity <Display Name> -ResultSize Unlimited |
   List DisplayName, PrimarySmtpAddress, EmailAddresses | 
   Format-List -Wrap  PrimarySmtpAddress, EmailAddresses

But when there are more then 1 EmailAddresses for a user, it keeps everything together. 但是,当一个用户的EmailAddresses超过1个时,它将使所有内容保持在一起。

I Would like to have the EmailAddresses split after each SPACE so it looks like this: 我想在每个SPACE之后拆分EmailAddresses ,所以它看起来像这样:

在此处输入图片说明

Get-MailBox -ResultSize Unlimited | Select DisplayName, PrimarySmtpAddress, `
 @{Name='Email';Expression={ $_.EmailAddresses.SmtpAddress -join "`n" }} |
Format-Table -Wrap

Should do it. 应该做。


The EmailAddresses property contains objects with many properties, there is no space to split on, because it's not a single string. EmailAddresses属性包含具有许多属性的对象,没有空格可分割,因为它不是单个字符串。 So you can't use -wrap to change it, because it's not a string being wrapped. 因此,您不能使用-wrap更改它,因为它不是要包装的字符串。 This answer uses a calculated property to turn all the email addresses into a string, which can then be -wrap ped. 此答案使用计算出的属性将所有电子邮件地址转换为字符串,然后可以将其-wrap


-ResultSize Unlimited is for returning lots of results, -Identity <displayname> is for returning a single result, using both together doesn't make much sense. -ResultSize Unlimited用于返回大量结果, -Identity <displayname>用于返回单个结果,将两者一起使用没有多大意义。

List is an alias for Format-List , so you're trying to pipe the output of Format-List back into Format-List, this is never going to do anything useful. ListFormat-List的别名,因此您尝试将Format-List的输出通过管道传递回Format-List,这永远不会做任何有用的事情。

Format-List output is a property list, but you describe your desired output as a table, it's the wrong command to give that kind of output. Format-List输出是一个属性列表,但是您将所需的输出描述为表,这是提供此类输出的错误命令。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM