Skip to content

Instantly share code, notes, and snippets.

@brettmillerb
Created July 23, 2018 14:12
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brettmillerb/f25dca2f3323c949510132a11f207b58 to your computer and use it in GitHub Desktop.
Save brettmillerb/f25dca2f3323c949510132a11f207b58 to your computer and use it in GitHub Desktop.
O365 License VSCode Snippet
"365-LicenseObject": {
"prefix": "O365-LicenseObject",
"body": [
"\\$enabledplans = 'SHAREPOINTWAC','YAMMER_ENTERPRISE','SHAREPOINTSTANDARD'",
"",
"#Get the licensesku and create the Disabled ServicePlans object",
"\\$licensesku = Get-AzureADSubscribedSku | Where-Object {\\$_.SkuPartNumber -eq '${License}'} ",
"\r",
"#Loop through all the individual plans and disable all plans except the one in \\$enabledplans",
"\\$disabledplans = \\$licensesku.ServicePlans | ForEach-Object -Process { ",
"\\$_ | Where-Object -FilterScript {\\$_.ServicePlanName -notin \\$enabledplans }",
"}",
"#Create the AssignedLicense object with the License and disabledplans created earlier\r",
"\\$licenseobj = New-Object -TypeName Microsoft.Open.AzureAD.Model.AssignedLicense\r",
"\\$licenseobj.SkuId = \\$licensesku.SkuId\r",
"\\$licenseobj.disabledplans = \\$disabledplans.ServicePlanId\r",
"\r",
"#Create the AssignedLicenses Object. Remove Licenses has to be declared as a null value",
"\\$assignedlicenseobj = New-Object -TypeName Microsoft.Open.AzureAD.Model.AssignedLicenses\r",
"\\$assignedlicenseobj.AddLicenses = \\$licenseobj\r",
"\\$assignedlicenseobj.RemoveLicenses = @()"
],
"description": "Creates an O365 License Object"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment