Advertisement
Guest User

Untitled

a guest
Apr 28th, 2017
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #Apply O365 licenses by group
  2.  
  3. Import-Module MSOnline
  4.  
  5. #Connect
  6. $Username = <user>
  7. $Password = <pw> | ConvertTo-SecureString -asPlainText -Force
  8. $Credentials = New-Object System.Management.Automation.PsCredential($Username,$Password)
  9. Connect-MsolService -Credential $Credentials
  10.  
  11. #Set groups and licensing options
  12. $StaffGroupID = "1f5fcf4d-1e07-4fbf-b2c6-896c9a8d8403"
  13. $StudentGroupID = "7a7c6427-4a6d-4b67-bbf8-4ab97a123646"
  14. $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"
  15. $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"
  16.  
  17. #Set usage location on all unlicensed users
  18. Get-MsolUser -All -UnlicensedUsersOnly | Set-MsolUser -UsageLocation AU
  19.  
  20. #Assign New Staff Licenses
  21. Get-MsolGroupMember -GroupObjectId $StaffGroupID -All | ?{$_.IsLicensed -eq $false} | ForEach-Object { Set-MsolUserLicense -UserPrincipalName $_.EmailAddress -AddLicenses "trafalgarhs:STANDARDWOFFPACK_FACULTY"; Set-MsolUserLicense -UserPrincipalName $_.EmailAddress -LicenseOptions $DisabledStaffPlans }
  22.  
  23. #Assign New Student Licenses
  24. 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