Created
September 13, 2016 00:15
-
-
Save darrenjrobinson/7dac49ac831e1ae919148a59ead0f7d7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Install-Module -Name AzureADPreview -RequiredVersion 2.0.0.1 -SkipPublisherCheck | |
Import-Module AzureADPreview -RequiredVersion 2.0.0.1 | |
# Tenant Name | |
$tenantID = "mytenant.com.au" | |
# Admin User for the Tenant | |
$username = "admin@mytenant.com.au" | |
# 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 "user@mytenant.com.au" | |
# Assigned License | |
$user.AssignedLicenses | |
$lic = $user.AssignedLicenses.SkuId | |
# Remove the license | |
$body = @{ | |
addLicenses = @() | |
removeLicenses= @($Lic) | |
} | |
Set-AzureADUserLicense -ObjectId "user@mytenant.com.au" -AssignedLicenses $body | |
# Read in the user to check license has been removed | |
$user = get-azureaduser -ObjectId "user@mytenant.com.au" | |
# Assigned Licenses should be empty | |
$user.AssignedLicenses | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment