我想让ProxyAddress的SMTP域格式为大写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"
答案 0 :(得分:0)
您恰好在{[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