如何从NoteProperty获取值?

时间:2016-05-02 19:31:23

标签: c# powershell office365

如何从NoteProperty获取值?

我正在使用powershell从Office365获取一些数据

Get-Mailbox | select EmailAddresses, UserPrincipalName, DisplayName, PrimarySmtpAddress

EmailAddresses是NoteProperty。该值类似于以下,包括SIP,X500,......

enter image description here

PowerShell中有一种简单的方法可以获得SIP值吗?或者,我必须使用C#代码来解析SIP值?

由于

2 个答案:

答案 0 :(得分:1)

喜欢这样(未经测试)?

$m = Get-Mailbox | select EmailAddresses, UserPrincipalName, DisplayName, PrimarySmtpAddress

#Get one mailbox
$t = $m[0]
$t.EmailAddresses | Where-Object { $_.PrefixString -eq "sip"} | ForEach-Object { $_.AddressString }

答案 1 :(得分:1)

我现在没办法测试它,但有一种方法可能是这样的:

Get-Mailbox | select EmailAddresses, UserPrincipalName, DisplayName, PrimarySmtpAddress, @{Name='SIPAddress';Expression={$PSItem.EmailAddresses -match "sip:"}}
相关问题