locked
Can't get powershell to assign Office 365 license in script. RRS feed

  • Question

  • To make things short, my co-worker and I have made a Powershell script that creates a new user and deploys them in the correct OU with DG added when put into a certain group. The only big problem I have in this mess, is having the script at the end assign a office 365 license.

    $cred = Get-Credential
    
    Connect-MsolService -Credential = $cred 
       
    Get-MsolUser -UserPrincipalName $UserID@Company.com | Set-MsolUser –UsageLocation US | Set-MsolUserLicense –AddLicenses "Company:EXCHANGEENTERPRISE"

    This is popup I get when the whole scrip runs.

    Supply Values for the following parameters:
    Get-MsolUser –UserPrincipalName $UserID@Company.com | Set-MsolUser –UsageLocation US | Set-MsolUserLicense –AddLicenses "Company:EXCHANGEENTERPRISE"





    • Edited by Thezy2 Friday, September 11, 2015 2:15 PM
    Friday, September 11, 2015 2:08 PM

Answers

  • Hi,

    Retype your dashes and quotation marks. They look like em/en and the quotes are bent.


    • Proposed as answer by Elaine Jing Thursday, September 24, 2015 7:50 AM
    • Marked as answer by Elaine Jing Monday, September 28, 2015 9:17 AM
    Friday, September 11, 2015 2:11 PM
  • Hi,

    I would agree with Mike and please check the article below for more information about assign office 365 license to users:

    http://windowsitpro.com/office-365/office-365-licensing-windows-powershell

    Hope it helps.

    Best Regards,

    Elaine


    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    • Proposed as answer by Elaine Jing Thursday, September 24, 2015 7:51 AM
    • Marked as answer by Elaine Jing Monday, September 28, 2015 9:17 AM
    Monday, September 14, 2015 10:10 AM

All replies

  • Hi,

    Retype your dashes and quotation marks. They look like em/en and the quotes are bent.


    • Proposed as answer by Elaine Jing Thursday, September 24, 2015 7:50 AM
    • Marked as answer by Elaine Jing Monday, September 28, 2015 9:17 AM
    Friday, September 11, 2015 2:11 PM
  • Hi,

    I would agree with Mike and please check the article below for more information about assign office 365 license to users:

    http://windowsitpro.com/office-365/office-365-licensing-windows-powershell

    Hope it helps.

    Best Regards,

    Elaine


    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    • Proposed as answer by Elaine Jing Thursday, September 24, 2015 7:51 AM
    • Marked as answer by Elaine Jing Monday, September 28, 2015 9:17 AM
    Monday, September 14, 2015 10:10 AM