Jump to content

Recommended Posts

Posted

Hi,

 

I've been using Office 365 at our College for a couple of yearsnow, and periodically we have been assigned new Licence SKU's.

 

I'm now at a point where where we have enough "Office 365Education Plus for students" for all students (giving them the OfficeApplications etc).

 

Problem I have is that I've got 1000's of licences cascaded over 3different SKU's. Ideally, I want all users transferred to the same License...

 

Has anyone successfully managed to do this? Preferably usingPowershell??

 

I'm no scripting expert, but I've found a couple of scripts thatI'm struggling to get working?

 

Something along these lines:

#Log in toMicrosoft online services

$LiveCred =Get-Credential

$Session = New-PSSession-ConfigurationName Microsoft.Exchange -ConnectionUrihttps://outlook.office365.com/powershell-liveid/ -Credential $LiveCred-Authentication Basic -AllowRedirection

Import-PSSession $Session-AllowClobber

Connect-MsolService-Credential $LiveCred

#set Variablesfor Your License

#change the Numbers inthe [] according to amount of license that you have

#run the'Get-MsolAccountSku' to set the location of each license

$SKU =Get-MsolAccountSku

$old =$SKU[1].AccountSkuId

$new =$SKU[2].AccountSkuId

$users =Get-MsolUser -MaxResults 5 | Where-Object { $_.isLicensed -eq "TRUE" }

foreach($user in$users)

{

if($user.Licenses.AccountSkuId-eq $old){

 

 

Set-MsolUserLicense-UserPrincipalName $user.UserPrincipalName -RemoveLicenses $old

Set-MsolUserLicense-UserPrincipalName $user.UserPrincipalName -AddLicenses $new

}

}

Any advicewould be very much appreciated.....

 

Thanks

Posted
The script should work fine, might want to change the MaxResults to a higher number but that's just to save time from running the script multiple times. The only thing to beware of is that Get-MSolAccountSku might not return the results in the same order each time, you'd be better off using a Where-Object on the end to identify the right ones.
  • Thanks 1
Posted

Yeah, I thought the script looked pretty straight forward... and it doesn't appear to fail at any point?? (the MaxResults was low just for testing purposes:D )

 

This is the output I get when I've ran the script:

 

PS C:\users\desktop> .\\ReplaceO365License.ps1

 

 

cmdlet Get-Credential at command pipeline position 1

Supply values for the following parameters:

Credential

WARNING: Some imported command names include unapproved verbs which might make

them less discoverable. Use the Verbose parameter for more detail or type

Get-Verb to see the list of approved verbs.

 

 

ModuleType Name ExportedCommands

---------- ---- ----------------

Script tmp_625ba2e4-34ef-4cfe... {Get-DeviceComplianceDetailsReportFilte...

 

 

Then when I run Get-MsolAccountSku - the numbers don't alter?

 

AccountSkuId ActiveUnits WarningUnits ConsumedUnits

------------ ----------- ------------ -------------

myc:EXCHANGESTANDARD... 7000 0 1779

myc:STANDARDWOFFPACK... 20000 0 15262

myc:STANDARDWOFFPACK... 1000000 0 301

myc:IT_ACADEMY_AD 1 0 0

myc:OFFICESUBSCRIPTI... 4700 0 108

 

Forgive my ignorance, I'm still very much a scripting novice - am I missing anything obvious?

 

Thanks

Posted
I'd guess that it can take a little while to update the Get-MsolAccountSku data, it's worth checking an individual user you've updated to ensure they've got the license Get-MsolUser -UserPrincipalName | Select Userprincipalname,Licenses should do the job, though you might want -expandproperty before licenses to make it it gets them all.
Posted

When we were looking at changing licences via PowerShell, there was a disclaimer that said to make sure you add the new licence before you removed the old one otherwise the mailbox contents could be removed.

 

In the end we just used the web GUI for our 1000 users as it kept giving us an error that is could not have 2 SharePoint licences applied at once.

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...