我试图通过某个许可证通过get-msoluser获取办公室365的用户。出于某种原因,我无法让它工作,因为$ user没有返回任何内容。我也是积极的,它也是正确的许可证。关于出了什么问题的任何想法。
$c = Get-Credential
Connect-MsolService -Credential $c
$accountsku = Get-MsolAccountSku
$userMSOL = Get-MsolUser -All | Where {$_.Licenses.AccountSku -eq $accountsku[0].AccountSkuId}
答案 0 :(得分:1)
Licenses
是集合属性(包含多个值),因此您需要替换表达式:
Where {$_.Licenses.AccountSku -eq $accountsku[0].AccountSkuId}
与
Where { $_.Licenses.accountskuid -contains $accountsku[0].AccountSkuId }
示例强>
$c = Get-Credential
Connect-MsolService -Credential $c
$accountsku = Get-MsolAccountSku
$userMSOL = Get-MsolUser -All | where { $_.Licenses.accountskuid -contains $accountsku[0].AccountSkuId }