Created
July 23, 2018 14:12
-
-
Save brettmillerb/f25dca2f3323c949510132a11f207b58 to your computer and use it in GitHub Desktop.
O365 License VSCode Snippet
This file contains hidden or 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
"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