【问题标题】:E-mail address that include a specific tenant domain name包含特定租户域名的电子邮件地址
【发布时间】:2019-01-24 06:22:20
【问题描述】:

我想让 ProxyAddress 具有大写 SMTP domain.onmicrosoft.com 和/或 domain.mail.onmicrosoft.com 格式的用户。

错误信息:

At line:1 char:218
+ ... pression={[string]::join(“;”, ($_.Licenses))} -ExpandProperty Proxyad ...
+                                                   ~~~~~~~~~~~~~~~
Unexpected token '-ExpandProperty' in expression or statement.
At line:1 char:234
+ ... ng]::join(“;”, ($_.Licenses))} -ExpandProperty Proxyaddresses | ? {$_ ...
+                                                    ~~~~~~~~~~~~~~
Unexpected token 'Proxyaddresses' in expression or statement.
At line:1 char:233
+ ... pression={[string]::join(“;”, ($_.Licenses))} -ExpandProperty Proxyad ...
+                                                                  ~
The hash literal was incomplete.
+ CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : UnexpectedToken

我试过如下:

Get-MSOLUser -All | Where-Object {$_.IsLicensed -eq $true -and $_.BlockCredential -eq $false} | Select-Object  FirstName, LastName, UserPrincipalName, @{Name=’Licenses’;Expression={[string]::join(“;”, ($_.Licenses))} -Expand Proxyaddresses | ? {$_ -cmatch '^SMTP\:.*@domain.onmicrosoft.com'} | Export-Csv C:\Users\Admin\Desktop\Userlist.csv

更新:

#TYPE System.String
"FirstName","LastName","UserPrincipalName","Licenses","Length"
"mailbox2",,"mailbox2@domain.onmicrosoft.com","Microsoft.Online.Administration.UserLicense","48"

【问题讨论】:

  • 你有没有让事情顺利进行?

标签: powershell office365 export-to-csv


【解决方案1】:

您在代码中缺少一个 },就在 {[string]::join(';', ($_.Licenses))} }

我建议您使用 VS 代码并使用扩展来为不同的父级和括号着色。

Get-MSOLUser -All | Where-Object {$_.IsLicensed -eq $true -and $_.BlockCredential -eq $false} | Select-Object  FirstName, LastName, UserPrincipalName, @{Name='Licenses';Expression={[string]::join(';', ($_.Licenses))}} -Expand Proxyaddresses | ? {$_ -cmatch '^SMTP\:.*@domain.onmicrosoft.com'} | Export-Csv C:\Users\Admin\Desktop\Userlist.csv

【讨论】:

  • 谢谢,但我无法获得许可证信息。我已经更新了我的答案。
猜你喜欢
  • 2023-01-28
  • 2013-04-24
  • 1970-01-01
  • 1970-01-01
  • 2013-09-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多