Share via

Powershell Script for Removing MSOL Licenses

Anonymous
2017-04-28T10:45:38+00:00

Hello,

I am trying to remove some licenses from a list of users I have and I have tried to use a the script posted here: https://technet.microsoft.com/en-us/library/dn771774.aspx to achieve this.

When I run the script it return the error: Set-MsolUserLicense : Cannot bind argument to parameter 'UserPrincipalName' because it is null.

At line:1 char:90

  • ... | Set-MsolUserLicense -UserPrincipalName $_.UserPrincipalName -Remove ...

Below is a copy of the script I am running from a remote PowerShell session on my computer: Get-Content "C:\Scripts\UserLicensesRemove.txt" | Set-MsolUserLicense -UserPrincipalName $_.UserPrincipalName -RemoveLicenses "XXXXXXX:ENTERPRISEPACK"

[Personal information removed by MSFT]

Please can you tell me where I am going wrong? Thanks.

Microsoft 365 and Office | Subscription, account, billing | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

2 answers

Sort by: Most helpful
  1. Anonymous
    2017-05-01T09:33:54+00:00

    Hi Marcus,

    Have you managed those licenses successfully?

    Regards,

    Fraser

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2017-04-28T15:51:26+00:00

    Hi Marcus,

    You can try this existing PowerShell scripts that wrote by other user to bulk manage your end users’ license: Office 365 License Reporting and Management Tool.

    It’s easy to use and have a simple window to allow you to perform your management.

    Note: Microsoft .Net 4.5 framework and Azure ActiveDirectory Module for Windows Powershell are the pre-requisites of using this module.

    If you don’t want to use this tool, since this issue may related to CSV file, so, could you share the file with us? I’ve sent you a private message for it. You can access your private message via https://answers.microsoft.com/en-us/privatemessages/list.

    Regards

    Fraser

    Was this answer helpful?

    0 comments No comments