2017-09-04 14 views
0

ユーザーの一覧のライセンスステータスを取得しようとしています。私はライセンスの状況に基づいて何かをします。属性クラスpowershellを取得する方法

例えばライセンスユーザ出力:

Get-AzureADUser -ObjectId "[email protected]" | fl 

DeletionTimestamp    : 
ObjectId      : 
ObjectType      : User 
AccountEnabled     : True 
AssignedLicenses    : {class AssignedLicense { 
            DisabledPlans: System.Collections.Generic.List`1[System.String] 
            SkuId: 6fd2c87f-b296-42f0-b197-1e91e994b900 
           } 
           } 

非ライセンスユーザ出力:

Get-AzureADUser -ObjectId "[email protected]" | fl 

DeletionTimestamp    : 
ObjectId      : 
ObjectType      : User 
AccountEnabled     : True 
AssignedLicenses    : {} 

私はAzureADのPowerShellでそれを取得する方法がわかりません。 AssignedLicenses属性内からSkuIdを取得するにはどうすればよいですか?

#for licence user 
if($AzureADUser.SkuId -eq '6fd2c87f-b296-42f0-b197-1e91e994b900') 
{ 
do something... 
} 

#for non-licence user 
elseif($AzureADUser.AssignedLicenses -eq $null) 
{ 
do something... 
} 

最終更新日:

Get-AzureADUser -ObjectId "[email protected]" | Select-Object -ExpandProperty AssignedLicenses 

DisabledPlans SkuId        
------------- -----        
{}   6fd2c87f-b296-42f0-b197-1e91e994b900 

非ライセンスユーザー:

Get-AzureADUser -ObjectId "[email protected]" | Select-Object -ExpandProperty AssignedLicenses 

何もあなたが直接このようSKUIDにアクセスすることができ

+0

私はコマンドをテストすることはできませんが、まずGet-AzureADUser -ObjectId "[email protected]"を使ってプロパティ 'AssignedLicenses'を展開する必要があると言います。 Select-Object -ExpandProperty AssignedLicenses'を選択します。 – Manu

+0

@ManuP私は自分の質問を更新しました。最後の更新セクションが表示されます。 – Arbelac

答えて

0

を返しません。

(Get-AzureADUser -ObjectId "[email protected]").AssignedLicenses.SkuID 

少なくとも1つのライセンスがあれば、あなたの質問にあるSelect-Object状態も機能します。それ以外の場合は、何も返されません。 :割り当てられたライセンスの数が、あなたはまた、使用しているすべてのユーザーとそのライセンスをつかむ可能性が0

(Get-AzureADUser -ObjectId "Andre2.contoso.com").AssignedLicenses.count 

に等しいことを示します何も返さないユーザーのために、あなたは次のことを実行することができます

$SKus = Get-AzureAdSubscribedSku | Select SkuPartNumber,SkuID 
$Users = Get-AzureADUser -All $true 
$Users | Select {$_.UserPrincipalName,$_.AssignedLicenses.SkuID} 

これで、すべてのユーザーと割り当てられたライセンスが一覧表示されます。 AssignedLicenses SKU IDは、ライセンスのないADユーザーの場合はnullになります。

SkuIDSに関連付けられているSku ID(SkuIDSをSkypeの名前と関連付けて、SkuIDSをライセンス別のライセンス、O365プレミアムライセンスなど)を決定することができます。 $ Skusハッシュテーブル。

関連する問題