通过Powershell获取具有特定域的Office 365用户

时间:2019-01-31 18:13:21

标签: powershell office365

我正在寻找一种从Office 365租户中导出用户列表的方法。

我尝试过如下操作:

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"

我想要的输出:

"FirstName","LastName","UserPrincipalName","Licenses","Proxyaddresses"
"mailbox",,"mailbox@domain.onmicrosoft.com","aksigorta365:STANDARDPACK","mailbox2@domain.onmicrosoft.com"

0 个答案:

没有答案