Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
# Install-Module -Name AzureADPreview -RequiredVersion -SkipPublisherCheck
Import-Module AzureADPreview -RequiredVersion
# Tenant Name
$tenantID = ""
# Admin User for the Tenant
$username = ""
# Password for the Admin User
$password = '**********' | convertto-securestring -AsPlainText -Force
$credentials = New-Object System.Management.Automation.PSCredential $Username,$password
#Connect to your AzureAD tenant
Connect-AzureAD -TenantId $tenantID -Credential $credentials -Confirm
# Removing a license
# Get the User
$user = get-azureaduser -ObjectId ""
# Assigned License
$lic = $user.AssignedLicenses.SkuId
# Remove the license
$body = @{
addLicenses = @()
removeLicenses= @($Lic)
Set-AzureADUserLicense -ObjectId "" -AssignedLicenses $body
# Read in the user to check license has been removed
$user = get-azureaduser -ObjectId ""
# Assigned Licenses should be empty
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.