Share via

Powershell new user issue

Anonymous
2024-04-25T19:29:22.9933333+00:00

Hello. I am currently trying to learn the basics of using Powershell with Office365 and one of those is creating a new user. I enter the below code as a test:

new-msoluser -UserPrincipalName "******@mirador.com" -DisplayName "Harp Yan" -Firstname "Harp" -LastName "Yan" -UsageLocation "IN" -LicenseAssignment "my license"

After typing the command, I get the error below:

WARNING: This licensing cmdlet has been retired. Please update to MS Graph Set-MgUserLicense: https://aka.ms/mguserlicense

I don't really understand what that means and how I can work around this. The videos I am watching are currently two years old so I would like to know if Powershell coding has changed. Any help would be appreciated. Thank you.

Microsoft 365 and Office | Install, redeem, activate | For business | Windows
Windows for business | Windows Server | User experience | PowerShell
Microsoft Security | Microsoft Graph
0 comments No comments

2 answers

Sort by: Most helpful
  1. Marcin Policht 92,960 Reputation points MVP Volunteer Moderator
    2024-04-25T19:43:55.2066667+00:00

    This means that you should not be using the PowerShell cmdlets that include "msol" in their name (following the "-" character).

    Instead, you should be using cmdlets which include "mg" in their name (following the "-" character).

    To create a user, follow https://learn.microsoft.com/en-us/microsoft-365/enterprise/create-user-accounts-with-microsoft-365-powershell?view=o365-worldwide

    To set a license, follow https://learn.microsoft.com/en-us/microsoft-365/enterprise/assign-licenses-to-user-accounts-with-microsoft-365-powershell?view=o365-worldwide


    If the above response helps answer your question, remember to "Accept Answer" so that others in the community facing similar issues can easily find the solution. Your contribution is highly appreciated.

    hth

    Marcin

    Was this answer helpful?

    1 person found this answer helpful.

  2. Anonymous
    2024-04-25T20:21:57.8066667+00:00

    Thanks for the response. When I type "Connect-MgGraph -Scopes "User.ReadWrite.All" in Powershell, I get an error saying that "Connect-MgGraph" is not recognized as the name of a cmdlet.

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.