Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Apply O365 licenses by group
- Import-Module MSOnline
- #Connect
- $Username = <user>
- $Password = <pw> | ConvertTo-SecureString -asPlainText -Force
- $Credentials = New-Object System.Management.Automation.PsCredential($Username,$Password)
- Connect-MsolService -Credential $Credentials
- #Set groups and licensing options
- $StaffGroupID = "1f5fcf4d-1e07-4fbf-b2c6-896c9a8d8403"
- $StudentGroupID = "7a7c6427-4a6d-4b67-bbf8-4ab97a123646"
- $DisabledStaffPlans = New-MsolLicenseOptions -AccountSkuID "trafalgarhs:STANDARDWOFFPACK_FACULTY" -DisabledPlans "TEAMS1", "Deskless", "FLOW_O365_P2", "POWERAPPS_O365_P2", "RMS_S_ENTERPRISE", "OFFICE_FORMS_PLAN_2", "PROJECTWORKMANAGEMENT", "INTUNE_O365", "YAMMER_EDU", "MCOSTANDARD"
- $DisabledStudentPlans = New-MsolLicenseOptions -AccountSkuID "trafalgarhs:STANDARDWOFFPACK_IW_STUDENT" -DisabledPlans "TEAMS1", "Deskless", "FLOW_O365_P2", "POWERAPPS_O365_P2", "RMS_S_ENTERPRISE", "OFFICE_FORMS_PLAN_2", "PROJECTWORKMANAGEMENT", "INTUNE_O365", "YAMMER_EDU", "MCOSTANDARD"
- #Set usage location on all unlicensed users
- Get-MsolUser -All -UnlicensedUsersOnly | Set-MsolUser -UsageLocation AU
- #Assign New Staff Licenses
- Get-MsolGroupMember -GroupObjectId $StaffGroupID -All | ?{$_.IsLicensed -eq $false} | ForEach-Object { Set-MsolUserLicense -UserPrincipalName $_.EmailAddress -AddLicenses "trafalgarhs:STANDARDWOFFPACK_FACULTY"; Set-MsolUserLicense -UserPrincipalName $_.EmailAddress -LicenseOptions $DisabledStaffPlans }
- #Assign New Student Licenses
- Get-MsolGroupMember -GroupObjectId $StudentGroupID -All | ?{$_.IsLicensed -eq $false} | ForEach-Object { Set-MsolUserLicense -UserPrincipalName $_.EmailAddress -AddLicenses "trafalgarhs:STANDARDWOFFPACK_IW_STUDENT"; Set-MsolUserLicense -UserPrincipalName $_.EmailAddress -LicenseOptions $DisabledStudentPlans }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement