Skip to main content
Version: Next

License helpers

Requires Microsoft Graph and a cached SKU catalog. For full details and examples, run Get-Help <FunctionName> -Detailed.

Primary and custom catalogs

SKU part numbers are resolved against the primary catalog (M365_licenses.json, sourced from Microsoft's official CSV) first, then against a custom catalog (M365_licenses_custom.json) for SKUs Microsoft hasn't published there yet. Both are cached locally and shown by Get-NebulaConfig. Lookup also strips invisible Unicode characters (e.g. zero-width spaces occasionally present in SkuPartNumber values returned by Graph for some tenants/SKUs) before matching, so those SKUs resolve correctly instead of showing up as unmapped.

Use Export-MsolAccountSku when you need:

  • a full tenant license assignment export
  • a domain-scoped report for a specific mail domain
  • a license-scoped report for users who hold a specific SKU, while still keeping all of their assigned licenses in the CSV
ScenarioUse this filterResult
Full exportnoneAll licensed users and all of their assigned licenses
Domain report-DomainOnly users in the selected domain, with all of their assigned licenses
License report-LicenseOnly users who have the selected license, with all of their assigned licenses
User identifier resolution

User-centric license cmdlets (Add/Get/Remove/Copy/Move-UserMsolAccountSku) support full UPNs/object IDs and short identifiers (for example alias/SamAccountName/UPN prefix) via the shared resolver. Now the resolver prefers a Microsoft Graph-friendly identity when available (-PreferGraphIdentity), improving reliability for object-ID-based lookups.

Add-UserMsolAccountSku​

Assign licenses by friendly name (resolved via catalog), SKU part number, or SKU ID to a user.

Syntax

Add-UserMsolAccountSku -UserPrincipalName <String> -License <String[]> [-ForceLicenseCatalogRefresh] [-ShowErrorDetails]
Add-UserMsolAccountSku <UserPrincipalName> -License <String[]> [-ForceLicenseCatalogRefresh] [-ShowErrorDetails]
ParameterTypeDescriptionRequiredDefault
UserPrincipalName (User, UPN)StringTarget user UPN, object ID, or short identifier.Yes-
LicenseString[]Friendly name, SKU part number, or SKU ID. Accepts multiple values.Yes-
ForceLicenseCatalogRefreshSwitchRedownload license catalog cache.NoFalse
ShowErrorDetailsSwitchKept for compatibility. Since 1.3.0 error messages always include the Microsoft Graph error detail, so this switch has no effect.NoFalse

Licenses the user already has are skipped with a warning: they don't use a seat, and the service plans disabled for that user stay disabled.

Examples

Add-UserMsolAccountSku -UserPrincipalName 'user@contoso.com' -License 'Microsoft 365 E3'
Add-UserMsolAccountSku -UserPrincipalName 'user@contoso.com' -License 'ENTERPRISEPACK','VISIOCLIENT'
Add-UserMsolAccountSku -UserPrincipalName 'user@contoso.com' -License '18181a46-0d4e-45cd-891e-60aabd171b4e'
Add-UserMsolAccountSku 'user@contoso.com' -License 'Microsoft 365 Business Standard EEA (no Teams)'
'user1@contoso.com','user2@contoso.com' | Add-UserMsolAccountSku -License 'Microsoft 365 Business Standard EEA (no Teams)'
Mandatory usage location parameter

If the target user has no UsageLocation, Nebula.Core sets it automatically using the UsageLocation key from your configuration (default US, override via %USERPROFILE%\.NebulaCore\settings.psd1). If updating the usage location fails, license assignment stops.

Licenses availability

If the tenant does not have units available for the requested license, the assignment is avoided and a warning message is displayed.

Copy-UserMsolAccountSku​

Copy all licenses (with disabled plans preserved) from one user to another without removing them from the source.

Syntax

Copy-UserMsolAccountSku -SourceUserPrincipalName <String> -DestinationUserPrincipalName <String>
Copy-UserMsolAccountSku <SourceUserPrincipalName> <DestinationUserPrincipalName>
ParameterTypeDescriptionRequiredDefault
SourceUserPrincipalName (Source, From)StringSource user UPN, object ID, or short identifier.Yes-
DestinationUserPrincipalName (Destination, To)StringDestination user UPN, object ID, or short identifier.Yes-

Example

Copy-UserMsolAccountSku -SourceUserPrincipalName 'user1@contoso.com' -DestinationUserPrincipalName 'user2@contoso.com'
Copy-UserMsolAccountSku 'user1@contoso.com' 'user2@contoso.com'
Licenses availability

Before assigning, Nebula.Core checks tenant seat availability for each source license. Licenses with no available units are skipped with a warning instead of failing the whole copy; every license that does have availability is still assigned.

Export-MsolAccountSku​

Export all users with assigned licenses to CSV, mapping SKU part numbers to friendly names. Use -Domain to limit the export to users whose Mail, UserPrincipalName, or ProxyAddresses match the domain. Use -License to limit the export to users who have at least one matching license, while still exporting all of the licenses assigned to those users.

Syntax

Export-MsolAccountSku [-CsvFolder <String>] [-Domain <String>] [-License <String[]>] [-ForceLicenseCatalogRefresh]
[-BatchSize <Int32>] [-Resume] [-CsvPath <String>] [-MaxConsecutiveErrors <Int32>]
ParameterTypeDescriptionRequiredDefault
CsvFolderStringOutput folder.NoCurrent directory
DomainStringLimit the export to users in the specified domain.No-
LicenseString[]Limit the export to users who have at least one matching license. Accepts friendly name, SKU part number, or SKU ID.No-
ForceLicenseCatalogRefreshSwitchRedownload the license catalog cache.NoFalse
BatchSizeInt32Number of processed users before flushing partial CSV output.No50
ResumeSwitchResume from the latest matching CSV in the target folder or from -CsvPath.NoFalse
CsvPathStringExplicit CSV file to resume. When omitted, the most recent matching CSV in the target folder is used.No-
MaxConsecutiveErrorsInt32Stop after this many consecutive user-level failures.No5

Example

Export-MsolAccountSku -CsvFolder 'C:\Temp\Reports'
Export-MsolAccountSku -Domain 'contoso.com'
Export-MsolAccountSku -License 'Exchange Online (Plan 1)'
License filtered export

When you pass -License, the CSV still includes every license assigned to each matching user. If a user has Exchange Online (Plan 1) plus Microsoft 365 E3, both rows are exported.

Get-TenantMsolAccountSku​

List tenant SKUs with resolved names, totals, consumed, available (enabled minus consumed), and seat states (filter by name or SKU part number).

Syntax

Get-TenantMsolAccountSku [-ForceLicenseCatalogRefresh] [-Filter <String>] [-Domain <String>] [-SampleUsers <Int32>] [-IncludeSampleUsers] [-AsTable] [-GridView]
ParameterTypeDescriptionRequiredDefault
ForceLicenseCatalogRefreshSwitchRedownload license catalog cache.NoFalse
FilterStringShow only licenses whose name or SkuPartNumber contains the provided text.No-
DomainStringLimit sample users to accounts whose Mail, UserPrincipalName, or ProxyAddresses belong to the domain.No-
SampleUsersInt32Return up to N sample users per license (requires -Filter).No5
IncludeSampleUsersSwitchReturn sample users using the default limit of 5 (requires -Filter).NoFalse
AsTableSwitchFormat output as a table.NoFalse
GridViewSwitchShow output in a GridView window.NoFalse

Example

Get-TenantMsolAccountSku -AsTable
Get-TenantMsolAccountSku -Filter "E3" -AsTable
Get-TenantMsolAccountSku -Filter "E3" -SampleUsers
Get-TenantMsolAccountSku -Filter "E3" -IncludeSampleUsers
Available licenses: how counting works

Available is calculated as Enabled - Consumed (never below zero). The Total column shows a friendly breakdown (Enabled/Suspended), while TotalCount remains the numeric total for scripting.

Sample users display

When you request sample users together with -AsTable, Nebula.Core prints the license summary as a table and then lists sample users in a separate readable block for each SKU. With -GridView, Nebula.Core opens a summary grid and, when sample users are requested, a second grid dedicated to sample users.

Microsoft 365 Subscriptions (Admin Portal)

Need renewal/expiration or billing profile details? Open the Microsoft 365 Admin Center subscriptions page: https://admin.cloud.microsoft/?#/subscriptions

Offline fallback to stale cache

If the license catalog file can't be downloaded from GitHub (network issue, GitHub outage, ...) after all retry attempts, Nebula.Core falls back to the last cached copy instead of failing, and prints a warning noting the cache is stale. The command still works, just with a possibly outdated SKU catalog. If no cache exists yet, the error is still raised.

Get-UserMsolAccountSku​

Show licenses assigned to a single user with friendly names.

No assigned licenses

If the target user exists but has no assigned licenses, Nebula.Core prints an explicit warning instead of returning only the processing header.

Syntax

Get-UserMsolAccountSku -UserPrincipalName <String> [-Clipboard] [-CheckAvailability] [-ForceLicenseCatalogRefresh] [-ShowErrorDetails]
Get-UserMsolAccountSku <UserPrincipalName> [-Clipboard] [-CheckAvailability] [-ForceLicenseCatalogRefresh] [-ShowErrorDetails]
ParameterTypeDescriptionRequiredDefault
UserPrincipalName (User, UPN)StringTarget UPN, object ID, or short identifier.Yes-
ClipboardSwitchCopy the resolved license names (fallback: SkuPartNumber) to the clipboard as "License1","License2".NoFalse
CheckAvailabilitySwitchShow tenant available seat counts for the assigned SKUs.NoFalse
ForceLicenseCatalogRefreshSwitchRedownload license catalog cache.NoFalse
ShowErrorDetailsSwitchKept for compatibility. Since 1.3.0 error messages always include the Microsoft Graph error detail, so this switch has no effect.NoFalse

Example

Get-UserMsolAccountSku -UserPrincipalName 'user@contoso.com'
'user1@contoso.com','user2@contoso.com' | Get-UserMsolAccountSku
Get-UserMsolAccountSku -UserPrincipalName 'user@contoso.com' -Clipboard
Get-UserMsolAccountSku -UserPrincipalName 'user@contoso.com' -CheckAvailability

Get-UserUsageLocation​

Read the current usage location for one or more users, next to the configured Nebula.Core default (UsageLocation), so you can compare them at a glance.

Syntax

Get-UserUsageLocation -UserPrincipalName <String[]>
ParameterTypeDescriptionRequiredDefault
UserPrincipalName (User, UPN, Identity)String[]User principal name, object ID, or short identifier. Pipeline accepted.Yes-

Examples

Get-UserUsageLocation -UserPrincipalName user@contoso.com
'user1@contoso.com','user2@contoso.com' | Get-UserUsageLocation
Get-MgUser -Filter "endsWith(userPrincipalName,'@contoso.com')" | Get-UserUsageLocation

Move-UserMsolAccountSku​

Move all licenses (with disabled plans preserved) from one user to another.

Syntax

Move-UserMsolAccountSku -SourceUserPrincipalName <String> -DestinationUserPrincipalName <String>
Move-UserMsolAccountSku <SourceUserPrincipalName> <DestinationUserPrincipalName>
ParameterTypeDescriptionRequiredDefault
SourceUserPrincipalName (Source, From)StringSource user UPN, object ID, or short identifier.Yes-
DestinationUserPrincipalName (Destination, To)StringDestination user UPN, object ID, or short identifier.Yes-

Example

Move-UserMsolAccountSku -SourceUserPrincipalName 'user1@contoso.com' -DestinationUserPrincipalName 'user2@contoso.com'
Move-UserMsolAccountSku 'user1@contoso.com' 'user2@contoso.com'
Licenses availability

Before assigning, Nebula.Core checks tenant seat availability for each source license. A license with no available units is left on the source (not removed) instead of failing the whole move; every license that does have availability is still assigned to the destination and removed from the source.

Remove-UserMsolAccountSku​

Remove licenses from a user by friendly name (resolved via catalog), SKU part number, or SKU ID.

Syntax

Remove-UserMsolAccountSku -UserPrincipalName <String> -License <String[]> [-ForceLicenseCatalogRefresh] [-ShowErrorDetails]
Remove-UserMsolAccountSku <UserPrincipalName> -License <String[]> [-ForceLicenseCatalogRefresh] [-ShowErrorDetails]
'user1@contoso.com','user2@contoso.com' | Remove-UserMsolAccountSku -License <String[]> [-ForceLicenseCatalogRefresh] [-ShowErrorDetails]
ParameterTypeDescriptionRequiredDefault
UserPrincipalName (User, UPN)StringTarget user UPN, object ID, or short identifier.Yes-
LicenseString[]Friendly name, SKU part number, or SKU ID. Accepts multiple values.Yes-
ForceLicenseCatalogRefreshSwitchRedownload license catalog cache.NoFalse
ShowErrorDetailsSwitchKept for compatibility. Since 1.3.0 error messages always include the Microsoft Graph error detail, so this switch has no effect.NoFalse
Remove-UserMsolAccountSku -UserPrincipalName <String> -All [-ForceLicenseCatalogRefresh] [-ShowErrorDetails]
ParameterTypeDescriptionRequiredDefault
UserPrincipalName (User, UPN)StringTarget user UPN, object ID, or short identifier.Yes-
AllSwitchRemove all assigned licenses.Yes-
ForceLicenseCatalogRefreshSwitchRedownload license catalog cache.NoFalse
ShowErrorDetailsSwitchKept for compatibility. Since 1.3.0 error messages always include the Microsoft Graph error detail, so this switch has no effect.NoFalse

Examples

Remove-UserMsolAccountSku -UserPrincipalName 'user@contoso.com' -License 'Microsoft 365 E3'
Remove-UserMsolAccountSku -UserPrincipalName 'user@contoso.com' -License 'ENTERPRISEPACK','VISIOCLIENT'
Remove-UserMsolAccountSku -UserPrincipalName 'user@contoso.com' -License '18181a46-0d4e-45cd-891e-60aabd171b4e'
Remove-UserMsolAccountSku 'user@contoso.com' -License 'Exchange Online (Plan 2)'
'user1@contoso.com','user2@contoso.com' | Remove-UserMsolAccountSku -License 'Exchange Online (Plan 1)'
Remove-UserMsolAccountSku -UserPrincipalName 'user@contoso.com' -All

Set-UserMsolAccountSku​

Apply requested license additions and removals for one or more users. Each user's additions and removals are submitted together in one Microsoft Graph request. Rows for the same resolved user are merged before the change is sent.

Syntax

Set-UserMsolAccountSku -UserPrincipalName <String> [-AddLicense <String[]>] [-RemoveLicense <String[]>] [-ForceLicenseCatalogRefresh] [-QuietNoChanges] [-WhatIf] [-Confirm]
Import-Csv -LiteralPath <String> | Set-UserMsolAccountSku [-ForceLicenseCatalogRefresh] [-QuietNoChanges] [-WhatIf] [-Confirm]
Parameter / CSV columnTypeDescriptionRequiredDefault
UserPrincipalNameStringUser UPN or object ID. Accepts pipeline input and a CSV column with this exact header.Yes-
AddLicenseString[]License(s) to add. Accepts a friendly name, SKU part number, or SKU ID; also accepted from a CSV column with this exact header.At least one required; both allowed-
RemoveLicenseString[]License(s) to remove. Accepts a friendly name, SKU part number, or SKU ID; also accepted from a CSV column with this exact header.At least one required; both allowed-
ForceLicenseCatalogRefreshSwitchRedownload license catalog cache.NoFalse
QuietNoChangesSwitchSuppress per-user No license changes needed for... messages. The final counters remain visible.NoFalse
ShowErrorDetailsSwitchKept for compatibility; Graph errors always include details.NoFalse
WhatIfSwitchPreview planned changes without changing licenses.NoFalse
ConfirmSwitchAsk before changing licenses.NoPrompted by default (high impact)

For CSV input, use English headers that match the parameter names. A row can add and remove licenses for the same user:

UserPrincipalName,AddLicense,RemoveLicense
user1@contoso.com,Microsoft 365 E3,Microsoft 365 Business Standard
user2@contoso.com,Microsoft 365 Business Standard,Exchange Online (Plan 1)

Use one license per cell. For multiple additions or removals for one user, add more rows with the same UserPrincipalName; they are merged before the change is sent.

Preview the file before applying it:

Import-Csv -LiteralPath 'C:\Temp\license-changes.csv' | Set-UserMsolAccountSku -WhatIf

The command prints each user's additions and removals, then reports totals for successfully changed, failed, unchanged, and skipped/not executed users. If any user fails, the output also lists that user's UPN and failure reason. Users are processed independently: an error for one user does not roll back successful changes for other users.

Group-assigned licenses

A license inherited only through a group cannot be removed with this command. Remove that license assignment from the group instead.

Usage location

When adding a license to a user without a usage location, Nebula.Core sets the configured default before assigning the license. If that update fails, the license change is not sent.

Use the swap command when seats must be freed first

Set-UserMsolAccountSku submits each user's additions and removals together, but it does not first remove licenses from multiple users as a coordinated exchange. For a two-user reciprocal exchange that depends on freeing tenant seats before assigning the opposite licenses, use Switch-UserMsolAccountSku.

Set-UserUsageLocation​

Update the usage location for one or more users. When -UsageLocation is omitted, the configured Nebula.Core default is used (UsageLocation, US unless overridden). Users already at the target value are skipped. Supports -WhatIf/-Confirm.

Syntax

Set-UserUsageLocation -UserPrincipalName <String[]> [-UsageLocation <String>] [-PassThru]
ParameterTypeDescriptionRequiredDefault
UserPrincipalName (User, UPN, Identity)String[]User principal name, object ID, or short identifier. Pipeline accepted.Yes-
UsageLocationStringTwo-letter country code to set.NoConfigured UsageLocation
PassThruSwitchEmit the processed users as objects.NoFalse

Examples

Set-UserUsageLocation -UserPrincipalName user@contoso.com -UsageLocation IT
'user1@contoso.com','user2@contoso.com' | Set-UserUsageLocation -UsageLocation DE

Switch-UserMsolAccountSku​

Exchange selected direct licenses between two users. To work in tenants without spare license seats, the command removes the selected licenses from both users before assigning them to the other user. Disabled service plans are preserved.

Syntax

Switch-UserMsolAccountSku [-FirstUserPrincipalName] <String> [-SecondUserPrincipalName] <String> -FirstUserLicense <String[]> -SecondUserLicense <String[]> [-ForceLicenseCatalogRefresh] [-WhatIf] [-Confirm]
Switch-UserMsolAccountSku [-FirstUserPrincipalName] <String> [-SecondUserPrincipalName] <String> -AllLicenses [-ExcludeLicense <String[]>] [-ForceLicenseCatalogRefresh] [-WhatIf] [-Confirm]

The two users can be passed by position (first and second); the license parameters must be named.

ParameterTypeDescriptionRequiredDefault
FirstUserPrincipalNameStringUPN or object ID of the first user.Yes-
FirstUserLicenseString[]License(s) to move from the first user. Accepts a friendly name, SKU part number, or SKU ID.For explicit selection-
SecondUserPrincipalNameStringUPN or object ID of the second user.Yes-
SecondUserLicenseString[]License(s) to move from the second user. Accepts a friendly name, SKU part number, or SKU ID.For explicit selection-
AllLicensesSwitchSelect all licenses on both users automatically. Only direct assignments can be moved; licenses both users already share are given back to both after the swap.One selection mode requiredFalse
ExcludeLicenseString[]With -AllLicenses, give these licenses back to their current users after the swap. Accepts a friendly name, SKU part number, or SKU ID.No-
ForceLicenseCatalogRefreshSwitchRedownload license catalog cache.NoFalse
WhatIfSwitchPreview the planned removal and reciprocal assignment without changing licenses.NoFalse
ConfirmSwitchAsk before removing and assigning licenses.NoPrompted by default (high impact)

Use either explicit license selections for both users, or -AllLicenses. The two modes cannot be combined. -ExcludeLicense is available only with -AllLicenses; each user must still have at least one distinct license to swap after exclusions. Licenses assigned through a group cannot be moved; if a selected license is group-assigned, the swap stops.

With -AllLicenses, excluded licenses and licenses shared by both users are removed together with the swapped ones, so both users are emptied, and then assigned again to the same user (with the same disabled service plans) in the reciprocal step. Leaving them in place would make the removal fail when one of their service plans depends on a swapped plan (for example, Power Automate Free needs an Exchange Online plan). Group-assigned excluded licenses stay where they are.

Examples

Preview an explicit swap:

Switch-UserMsolAccountSku `
-FirstUserPrincipalName 'user1@contoso.com' `
-FirstUserLicense 'Microsoft 365 E3','Microsoft 365 E5 Security' `
-SecondUserPrincipalName 'user2@contoso.com' `
-SecondUserLicense 'Microsoft 365 Business Premium','Microsoft Defender Suite for Microsoft 365 Business Premium' `
-WhatIf

Swap all movable licenses and give Fabric back to its current user:

Switch-UserMsolAccountSku 'user1@contoso.com' 'user2@contoso.com' `
-AllLicenses `
-ExcludeLicense 'Microsoft Fabric (Free)' `
-WhatIf
Temporary license removal

The command removes the selected licenses from both users before assigning them reciprocally. This avoids needing spare tenant seats, but licensed services can be temporarily affected during the swap. If a removal or assignment fails, Nebula.Core attempts to restore the original assignments and reports any recovery that did not complete. On success, it prints one confirmation line per user with the licenses received.

Update-LicenseCatalog​

Refresh the local license catalog cache (download SKU mappings). It always redownloads the primary and custom catalogs, regardless of cache age.

Syntax

Update-LicenseCatalog
  • No parameters.

Example

Update-LicenseCatalog

Questions and answers​

Can I export licenses/mailboxes without Graph?​

No. License functions and some statistics require Microsoft Graph for complete data. Ensure Connect-Nebula requested the right scopes.