Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Assign Office365 Licenses using PowerShell and Graph API. Associated blog post can be found here
# License Body for RestAPI
$body = @{
addLicenses = @(@{"skuId" = $LicenceToAdd})
removeLicenses= @()
# Convert it to JSON
$postbody = $body | ConvertTo-Json
# License Users
foreach ($usertolicense in $unlicencedUsers){
$AssignLicense = Invoke-RestMethod -Method Post -Headers @{
Authorization = $authenticationResult.CreateAuthorizationHeader()
'Content-Type' = "application/json"
} -body $postbody -Uri ("$usertolicense`/assignLicense?api-version=1.6" -f $authenticationResult.TenantId)
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.