Advertisement
Guest User

Untitled

a guest
Sep 12th, 2016
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. # Install-Module -Name AzureADPreview -RequiredVersion 2.0.0.1 -SkipPublisherCheck
  2. Import-Module AzureADPreview -RequiredVersion 2.0.0.1
  3.  
  4. # Tenant Name
  5. $tenantID = "mytenant.com.au"
  6.  
  7. # Admin User for the Tenant
  8. $username = "admin@mytenant.com.au"
  9. # Password for the Admin User
  10. $password = '**********' | convertto-securestring -AsPlainText -Force
  11. $credentials = New-Object System.Management.Automation.PSCredential $Username,$password
  12.  
  13. #Connect to your AzureAD tenant
  14. Connect-AzureAD -TenantId $tenantID -Credential $credentials -Confirm
  15.  
  16. # Removing a license
  17. # Get the User
  18. $user = get-azureaduser -ObjectId "user@mytenant.com.au"
  19.  
  20. # Assigned License
  21. $user.AssignedLicenses
  22. $lic = $user.AssignedLicenses.SkuId
  23.  
  24. # Remove the license
  25. $body = @{
  26. addLicenses = @()
  27. removeLicenses= @($Lic)
  28. }
  29. Set-AzureADUserLicense -ObjectId "user@mytenant.com.au" -AssignedLicenses $body
  30.  
  31. # Read in the user to check license has been removed
  32. $user = get-azureaduser -ObjectId "user@mytenant.com.au"
  33. # Assigned Licenses should be empty
  34. $user.AssignedLicenses
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement