StephenHardy Posted June 20, 2014 Posted June 20, 2014 Hi guys, I'm trying to auto-provision/license staff with one plan and students with another in Office 365. I was looking at this: How to Use PowerShell to Automatically Assign Licenses to Your Office 365 Users - TechNet Articles - United States (English) - TechNet Wiki but not being great with LDAP or Powershell, anyone have an idea: I want it to use my 'students' group as the group it looks to to provision students with one of the SKU's (Not that I can see the actual full SKU yet) - any ideas on the ldapDisplayName I need to enter here? Thanks Stephen
Jasbo Posted June 20, 2014 Posted June 20, 2014 Hi, I did see that article a while back and decided it was a PITA, there's some topics on here about this that enabled me to get a working script to assign different licensing combinations to staff and students, will send you mine via pm on Monday if you what to take a look?
StephenHardy Posted June 21, 2014 Author Posted June 21, 2014 PITA - got it yes indeed, it really shouldn't be that damn hard. I have 4 user groupings. Teaching, non-teaching, domain admins and students, I want the staff types to have one set of licences and a mailbox created and students a different licence and mailbox. Pretty simple, and if I used an on site exchange it would be easy...
Asgard Posted June 21, 2014 Posted June 21, 2014 Stephen Not exactly sure I have what you need but I have two Powershell scripts that assign our staff with one script and students with a second. This is because we have our staff on our main domain with our students on a sub @student domain I'll log on shortly and get the code
EduTech Posted June 21, 2014 Posted June 21, 2014 I will smile for now, but in terms of today let me try and get you something that will handle this via PowerShell. In terms of how you define the groups of users, do you do this via Security Group or do you have a specific attribute populated? Thanks, James.
Asgard Posted June 21, 2014 Posted June 21, 2014 (edited) We do it via Active Directory OU membership (our staff and students are in separate OU's), this is for our Students; Import-module ActiveDirectory $AccountSkuId = "OUR-TENNANT-NAME[/b]:STANDARDWOFFPACK_STUDENT" $UsageLocation = "GB" $LicenseOptions = New-MsolLicenseOptions -AccountSkuId $AccountSkuId $Users = Get-ADUser -Filter * -SearchBase "OU=Students,DC=%domain%,dc=%domain%,dc=ac,dc=uk" $Users | ForEach-Object { Set-MsolUser -UserPrincipalName $_.UserPrincipalName -UsageLocation $UsageLocation Set-MsolUserLicense -UserPrincipalName $_.UserPrincipalName -AddLicenses $AccountSkuId -LicenseOptions $LicenseOptions } We have this saved as 'Students.ps1' and at the start of term run it as a scheduled task 3 times a day, but after the term has settled down we run it once a night/ or sometimes manually as after our main September intake we don't have a lot of students joining, etc. Edited June 21, 2014 by Asgard
StephenHardy Posted June 22, 2014 Author Posted June 22, 2014 We use group memberships to security groups James. I'd also like to know how on earth to read the SKUs when they appear to be over a certain character length 😜
StephenHardy Posted June 22, 2014 Author Posted June 22, 2014 Our student are in nested OUs under a main students one and staff are in other OUs so jszkudlapski's script may work..anyway to store the admin username and password though so it runs silently?
StephenHardy Posted June 23, 2014 Author Posted June 23, 2014 This script kind of works: Import-Module MSOnline $powerUser = "[email protected]" $powerPass = "XXXXXX" $password = ConvertTo-SecureString $powerPass -AsPlainText -Force $adminCredential = New-Object -TypeName System.Management.Automation.PSCredential -argumentlist $powerUser,$password Connect-MSOLService -Credential $adminCredential Import-module ActiveDirectory $AccountSkuId = "XXXXXX:STANDARDWOFFPACK_STUDENT" $UsageLocation = "GB" $LicenseOptions = New-MsolLicenseOptions -AccountSkuId $AccountSkuId $Users = Get-ADUser -Filter * -SearchBase "OU=Students,OU=XXX,OU=Establishments,DC=XXX,DC=XXX" $Users | ForEach-Object { Set-MsolUser -UserPrincipalName $_.UserPrincipalName -UsageLocation $UsageLocation Set-MsolUserLicense -UserPrincipalName $_.UserPrincipalName -AddLicenses $AccountSkuId -LicenseOptions $LicenseOptions } it throws errors RE: Being unable to assign licenses to existing licensed users Set-MsolUserLicense : Unable to assign this license because it is invalid. Use the Get-MsolAccountSku cmdlet to retrieve a list of valid licenses. At C:\XXXX Office 365 Scripts\Office 365\Students_Provision.ps1:15 char:2 + Set-MsolUserLicense -UserPrincipalName $_.UserPrincipalName -AddLicenses $Accou ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : OperationStopped: ( [set-MsolUserLicense], MicrosoftOnlineException + FullyQualifiedErrorId : Microsoft.Online.Administration.Automation.InvalidUserLicenseException,Microsoft.Online.Administration.Automation.SetUserLicense However, I now need to do the following: A) Copy every email either sent or received to every user into a separate email account for protection purposes B) Hide teaching staff from Students GAL Anyone have any ideas? Thanks Stephen
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now