Get-EntraSubscribedSku
サブスクライブされた SKU をMicrosoft サービスに取得します。
構文
GetQuery (既定)
Get-EntraSubscribedSku
[-Property <String[]>]
[<CommonParameters>]
GetById
Get-EntraSubscribedSku
-SubscribedSkuId <String>
[-Property <String[]>]
[<CommonParameters>]
説明
Get-EntraSubscribedSku コマンドレットは、サブスクライブされた SKU をMicrosoft サービスに取得します。
職場または学校のアカウントを使用する委任されたシナリオでは、別のユーザーを操作する場合、サインインしているユーザーはサポートされているMicrosoft Entraロールまたは必要なアクセス許可を持つカスタム ロールを持っている必要があります。 この操作は、次の最小特権ロールでサポートされています。
- Dynamics 365 Business Central管理者 (標準プロパティへの読み取り専用アクセス)
- グローバルリーダー
- ディレクトリの読み手
例
例 1: サブスクライブされた SKU を取得する
Connect-Entra -Scopes 'Organization.Read.All', 'LicenseAssignment.Read.All'
Get-EntraSubscribedSku
Id AccountId AccountName AppliesTo CapabilityStatus ConsumedUnits SkuId SkuPartNumber
-- --------- ----------- --------- ---------------- ------------- ----- -------
aaaa0000-bb11-2222-33cc-444444dddddd 0000aaaa-11bb-cccc-dd22-eeeeee333333 M365x99297270 User Enabled 20 aaaaaaaa-0b0b-1c1c-2d2d-333333333333 EMSP...
bbbb1111-cc22-3333-44dd-555555eeeeee 1111bbbb-22cc-dddd-ee33-ffffff444444 M365x99297270 User Enabled 20 bbbbbbbb-1c1c-2d2d-3e3e-444444444444 ENTE...
cccc2222-dd33-4444-55ee-666666ffffff 2222cccc-33dd-eeee-ff44-aaaaaa555555 M365x99297270 User Enabled 2 cccccccc-2d2d-3e3e-4f4f-555555555555 ENTE...
この例では、サブスクライブした SKU を取得してMicrosoft サービスする方法を示します。
例 2: SubscribedSkuId によってサブスクライブされた SKU を取得する
Connect-Entra -Scopes 'Organization.Read.All', 'LicenseAssignment.Read.All'
Get-EntraSubscribedSku -SubscribedSkuId 'abcdefgh-1111-2222-bbbb-cccc33333333_dddddddd-4444-5555-eeee-666666666666'
Id AccountId AccountName AppliesTo CapabilityStatus ConsumedUnits SkuId SkuPartNumber
-- --------- ----------- --------- ---------------- ------------- ----- -------
aaaa0000-bb11-2222-33cc-444444dddddd 0000aaaa-11bb-cccc-dd22-eeeeee333333 M365x99297270 User Enabled 20 aaaaaaaa-0b0b-1c1c-2d2d-333333333333 EMSP...
この例では、指定したサブスクライブ済み SKU を取得してMicrosoft サービスする方法を示します。
-
-SubscribedSkuIdパラメーターは、SKU の ID (在庫保管単位) を指定します。
例 3: 使用可能なライセンス プランを取得する
Connect-Entra -Scopes 'User.ReadWrite.All', 'Organization.Read.All', 'LicenseAssignment.Read.All'
Get-EntraSubscribedSku | Select-Object -Property Sku*, ConsumedUnits -ExpandProperty PrepaidUnits
Enabled : 5
LockedOut : 0
Suspended : 0
Warning : 0
AdditionalProperties :
SkuId : efccb6f7-5641-4e0e-bd10-b4976e1bf68e
SkuPartNumber : EMS
ConsumedUnits : 3
この例では、使用可能なライセンス プランを取得する方法を示します。
例 4: 特定のライセンスが割り当てられているすべてのユーザーを取得する
Connect-Entra -Scopes 'Organization.Read.All', 'LicenseAssignment.Read.All'
$sku = Get-EntraSubscribedSku | Where-Object { $_.SkuPartNumber -eq 'DEVELOPERPACK_E5' }
$skuId = $sku.SkuId
$usersWithDeveloperPackE5 = Get-EntraUser -All | Where-Object {
$_.AssignedLicenses -and ($_.AssignedLicenses.SkuId -contains $skuId)
}
$usersWithDeveloperPackE5 | Select-Object Id, DisplayName, UserPrincipalName, AccountEnabled, UserType | Format-Table -AutoSize
Id DisplayName UserPrincipalName AccountEnabled UserType
-- ----------- ----------------- -------------- --------
cccccccc-2222-3333-4444-dddddddddddd Angel Brown AngelB@contoso.com True Member
dddddddd-3333-4444-5555-eeeeeeeeeeee Avery Smith AveryS@contoso.com True Member
eeeeeeee-4444-5555-6666-ffffffffffff Sawyer Miller SawyerM@contoso.com True Member
この例では、特定のライセンスが割り当てられているすべてのユーザーを取得する方法を示します。
例 5: ユーザー、割り当てられたライセンス、ライセンス ソースの一覧を取得する
Connect-Entra -Scopes 'Organization.Read.All', 'User.Read.All', 'Group.Read.All', 'LicenseAssignment.Read.All'
# Get all users with specified properties
$Users = Get-EntraUser -All -Property AssignedLicenses, LicenseAssignmentStates, DisplayName, UserPrincipalName, ObjectId
$SelectedUsers = $Users | Select-Object ObjectId, UserPrincipalName, DisplayName, AssignedLicenses -ExpandProperty LicenseAssignmentStates
# Group Name lookup
$GroupDisplayNames = @{}
# Sku Part Number lookup
$SkuPartNumbers = @{}
# Populate the hashtable with group display names and SKU part numbers
foreach ($User in $SelectedUsers) {
$AssignedByGroup = $User.AssignedByGroup
$SkuId = $User.SkuId
try {
# Check if the group display name is already in the hashtable
if (-not $GroupDisplayNames.ContainsKey($AssignedByGroup)) {
$Group = Get-EntraGroup -GroupId $AssignedByGroup
$GroupDisplayNames[$AssignedByGroup] = $Group.DisplayName
}
$User | Add-Member -NotePropertyName 'GroupDisplayName' -NotePropertyValue $GroupDisplayNames[$AssignedByGroup]
}
catch {
$User | Add-Member -NotePropertyName 'GroupDisplayName' -NotePropertyValue 'N/A (Direct Assignment)'
}
try {
# Check if the SKU part number is already in the hashtable
if (-not $SkuPartNumbers.ContainsKey($SkuId)) {
$Sku = Get-EntraSubscribedSku | Where-Object { $_.SkuId -eq $SkuId } | Select-Object -ExpandProperty SkuPartNumber
$SkuPartNumbers[$SkuId] = $Sku
}
$User | Add-Member -NotePropertyName 'SkuPartNumber' -NotePropertyValue $SkuPartNumbers[$SkuId]
}
catch {
$User | Add-Member -NotePropertyName 'SkuPartNumber' -NotePropertyValue 'N/A'
}
}
$SelectedUsers | Format-Table UserPrincipalName, DisplayName, AssignedByGroup, GroupDisplayName, SkuId, SkuPartNumber, State, Error -AutoSize
userPrincipalName displayName assignedByGroup GroupDisplayName skuId SkuPartNumber state error
----------------- ----------- --------------- ---------------- ----- ------------- ----- -----
averyh@contoso.com Avery Howard cccccccc-2222-3333-4444-dddddddddddd Contoso Team abcdefgh-1111-2222-bbbb-cccc33333333 ENTERPRISEPACK Active None
devont@contoso.com Devon Torres ffffffff-5555-6666-7777-aaaaaaaaaaaa Retail abcdefgh-1111-2222-bbbb-cccc33333333 ENTERPRISEPACK Active None
この例では、ユーザー、ライセンス、ライセンスのソース (直接割り当て済み、グループ割り当てなど) の一覧を示します。
パラメーター
-Property
返されるプロパティを指定します。
パラメーターのプロパティ
| 型: | System.String[] |
| 規定値: | None |
| ワイルドカードのサポート: | False |
| DontShow: | False |
| Aliases: | Select |
パラメーター セット
(All)
| 配置: | Named |
| 必須: | False |
| パイプラインからの値: | False |
| プロパティ名別のパイプラインからの値: | False |
| 残りの引数からの値: | False |
-SubscribedSkuId
SKU のオブジェクト ID (在庫保管単位)。
パラメーターのプロパティ
| 型: | System.String |
| 規定値: | None |
| ワイルドカードのサポート: | False |
| DontShow: | False |
| Aliases: | オブジェクト識別子 |
パラメーター セット
GetById
| 配置: | Named |
| 必須: | True |
| パイプラインからの値: | True |
| プロパティ名別のパイプラインからの値: | True |
| 残りの引数からの値: | False |
CommonParameters
このコマンドレットでは、一般的なパラメーター -Debug、-ErrorAction、-ErrorVariable、-InformationAction、-InformationVariable、-OutBuffer、-OutVariable、-PipelineVariable、-ProgressAction、-Verbose、-WarningAction、-WarningVariable の各パラメーターがサポートされています。 詳細については、about_CommonParametersを参照してください。