Skip to content

Instantly share code, notes, and snippets.

@mattmcnabb
Last active May 11, 2017 01:48
Show Gist options
  • Save mattmcnabb/046774cab99eecb091a458ea407f752b to your computer and use it in GitHub Desktop.
Save mattmcnabb/046774cab99eecb091a458ea407f752b to your computer and use it in GitHub Desktop.
Blog_Office-365-Licensing_4
$LicenseTemplate = @(
@{
AccountSkuId = 'whitehouse:ENTERPRISEPACK'
EnabledPlans = 'EXCHANGE_S_STANDARD','SHAREPOINTENTERPRISE','SHAREPOINTWAC','MCOSTANDARD','YAMMER_ENTERPRISE'
},
@{
AccountSkuId = 'whitehouse:PROJECTONLINE'
EnabledPlans = 'SWAY'
}
)
$AccountSkuIds = Get-MsolAccountSku
$LicenseOptions = foreach ($Item in $LicenseTemplate)
{
$AllPlans = ($AccountSkuIds | Where-Object AccountSkuId -eq $Item.AccountSkuId).ServiceStatus
$DisabledPlans = ($AllPlans | Where-Object { $_.ServicePlan.ServiceName -notin $Item.EnabledPlans }).ServicePlan.ServiceName
New-MsolLicenseOptions -AccountSkuId $Item.AccountSkuId -DisabledPlans $DisabledPlans
}
try
{
$Splat = @{
UserPrincipalName = abe.lincoln@whitehouse.gov
AddLicenses = whitehouse:ENTERPRISEPACK
LicenseOptions = $Options
}
Set-MsolUserLicense @Splat -ErrorAction Stop
}
catch [Microsoft.Online.Administration.Automation.MicrosoftOnlineException]
{
$Splat.Remove('AddLicenses')
Set-MsolUserLicense @Splat -ErrorAction Stop
}
# Sales users will get Exchange and Skype
# Engineers will get Exchange and Sharepoint
$Sales = Get-MsolUser -Department Sales -All
$Engineering = Get-MsolUser -Department Engineering -All
$SalesTemplate = @{
AccountSkuId = "contoso:ENTERPRISEPACK"
EnabledPlans = "EXCHANGE_S_STANDARD","MCOSTANDARD"
}
$EngineeringTemplate = @(
@{
AccountSkuId = contoso:ENTERPRISEPACK
EnabledPlans = "EXCHANGE_S_STANDARD"
},
@{
AccountSkuId = "contoso:PROJECTONLINE"
EnabledPlans = "SHAREPOINT_PROJECT","SHAREPOINTENTERPRISE"
}
)
$Sales | Set-O365UserLicense -LicenseTemplate $SalesTemplate
$Engineering | Set-O365UserLicense -LicenseTemplate $EngineeringTemplate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment