Skip to content

Instantly share code, notes, and snippets.

@darrenjrobinson
Last active December 1, 2018 22:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save darrenjrobinson/161de54bd8aefdfd7857daba508db15b to your computer and use it in GitHub Desktop.
Save darrenjrobinson/161de54bd8aefdfd7857daba508db15b to your computer and use it in GitHub Desktop.
Get Office365 Licenses using PowerShell. Associated blog post can be found here https://blog.darrenjrobinson.com/adding-removing-user-office365-licences-using-powershell-and-the-azure-ad-graph-restapi/
# Licenses
$Licenses = Invoke-RestMethod -Method Get -Headers @{
Authorization = $authenticationResult.CreateAuthorizationHeader()
'Content-Type' = "application/json"
} -Uri ("https://graph.windows.net/{0}/subscribedSkus?api-version=1.6" -f $authenticationResult.TenantId)
# All Licenses avail
$Licenses.value.skuPartNumber
# Query to get the skuId for the skuPartNumber of ExchangeStandard_Student
$LicenceToAdd = $Licenses.value.skuId | Where-Object{$licenses.value.skuPartNumber -eq 'EXCHANGESTANDARD_STUDENT'}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment