Jump to content

Recommended Posts

Posted

Hi

 

This may or not be in the right place.

 

I am new to the delights of Powershell. So a little bg info

 

I was given the delightful task of syncing our AD with Office365, having had no training in Office365 this task was daunting to say the least as a friend in another school wiped his AD.

 

To cut a long story short, all was hunkydory, all staff and students synced.

 

Now to the fun part, giving our students Licenses. For months I was looking to be able to do this in bulk rather than 20 kids at a time, when I stumbled on a script written by Nathan O'Bryan (http://www.mcsmlab.com ). It was a revelation, it did exactly what I wanted it to do as our students are named by year they started i.e 16?????@???????????.com.

 

Recently we updated our subscriptions to be able to give them email addresses :rolleyes:, but not to give them all plans involved with the subscription, after a long and harduous search I once again stumbled on a gem from Todd Klindt (Using PowerShell to Specify License Plans in Office 365 - Todd Klindt's SharePoint Admin Blog) with a little tweaking for what I wanted this worked fantastically until very recently when Microsoft in their infinite wisdom giveth and taketh away.

 

I am having a little trouble getting this small script to work with AzureADs commandlets "Get-MsolUser –SearchString ?? | Set-MsolUser –UsageLocation GB | Set-MsolUserLicense –AddLicenses myschool:STANDARDWOFFPACK_STUDENT -LicenseOptions $opts"

 

Is there anyone out there who could point me in the right direction?

 

Many thanks

 

Lee

Posted (edited)

Hi

 

Well "get-msoluser -searchstring" doesn't exist in the new azure powershell, so that doesn't work straightaway.

 

Users were already licensed with another subscription, but I was able to add the new sub and licenses for 2 year groups with this script a couple of weeks ago. Due to time restrictions and holidays, the other year groups didn't get done, when the time came to run the script for them we already had had to install azuread powershell.

 

Lee

Edited by sychosis
sp
Posted (edited)

I can still use Get-MsolUser after installing V2 powershell, maybe I was not following best practice?

 

Anyway you can replace Get-MsolUser cmdlet with Get-AzureADUser. The license part is a little bit trickier because Set-AzureADUserLicense accepts different parameters.

 

The best way to do probably is to assign the needed licenses to a template user and then construct a license object from that user and pass it to Set-AzureADUserLicense

 

$license = (Get-AzureADUser -ObjectId [template_user]).AssignedLicenses

$licensetable = New-Object -TypeName Microsoft.Open.AzureAD.Model.AssignedLicenses

$licensetable.AddLicenses =$license

 

Get-AzureADUser -SearchString ?? | Set-AzureADUserLicense -AssignedLicenses $licensetable

Edited by xlandhenry

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 account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...