如何从 NoteProperty 中获取值?

How to get the value from NoteProperty?

如何获取NoteProperty的值?

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

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

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

powershell有没有简单的获取SIP值的方法?或者,我必须使用 C# 代码来解析 SIP 值?

谢谢

像这样(未测试)?

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

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

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

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