How do i powershell several licenses from E3 to E1?


We are changing several accounts from E3 to E1 and I need a Method to automate this.

My thought is to create a Text file with the Account names like and name it E3toE1Feed.txt

Then Run:

Get-Content "D:\E3toE1Feed.txt" | Set-MsolUserLicense -UserPrincipalName $_.UserPrincipalName -AddLicenses "mydomain:STANDARDPACK"



I get this Error:

Set-MsolUserLicense : Cannot bind argument to parameter 'UserPrincipalName' because it is null.
At line:1 char:81
+ ... | Set-MsolUserLicense -UserPrincipalName $_.UserPrincipalName -AddLic ...
+                                              ~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Set-MsolUserLicense], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.Online.Administration.Automatio


Anybody what I'm doing wrong? or a better method?


5 Replies
You have to use a csv file instead and then use a “for each” for each row in the csv:


You'll probably just have to use foreach.


Something like:


Get-Content "D:\E3toE1Feed.txt" | % { Set-MsolUserLicense -UserPrincipalName $_ -AddLicenses "mydomain:STANDARDPACK" }

Quadrotech - Management, Reporting and Migration for Office 365 and Exchange

There are multiple scripts out there that you can just reuse, this one will make the switch while preserving the status of any individually enabled/disabled services:

My fix was this:

#Converts the Content of CSV file from E3 to E1 License
#Set Variable for What is Old and What is New
$oldLicense = "yourdomain:ENTERPRISEPACK"
$newLicense = "yourdomain:STANDARDPACK"

#Define source to work with
$users = import-csv .\E3toE1Group3.csv

#Process each Account in import file
foreach ($user in $users) {Set-MsolUserLicense -UserPrincipalName $users.userprincipalname -AddLicenses $newLicense -RemoveLicenses $oldLicense  }