Cannot create New Entra ID User using Powershell

PHYO AUNG KYAW 0 Reputation points
2024-06-02T13:49:01.2233333+00:00

I am using PowerShell to connect to Microsoft Graph to create new users in Entra ID. I changed Graph version to too many versions but still got these errors. What is wrong with Microsoft? I am using Global Administrator account.
User's image

Windows for business | Windows Server | User experience | PowerShell
Microsoft Security | Microsoft Entra | Microsoft Entra ID
{count} votes

1 answer

Sort by: Most helpful
  1. Abiola Akinbade 30,360 Reputation points Volunteer Moderator
    2024-06-02T14:05:30.7866667+00:00

    Hello PHYO AUNG KYAW,

    Thanks for your question.

    THE Get-MgUser cmdlet expects and object after.

    The correct syntax for Get-MgUser is

    Get-MgUser -UserId '<id>' |

    see examples here: https://learn.microsoft.com/en-us/powershell/module/microsoft.graph.users/get-mguser?view=graph-powershell-1.0#example-2-get-a-user-by-id

    This is same for New-MgUser:

    See usage here: https://learn.microsoft.com/en-us/powershell/module/microsoft.graph.users/new-mguser?view=graph-powershell-1.0#example-1-create-a-new-user

    Please let me know if you have further questions**

    You can mark it 'Accept Answer' if this helped.

    0 comments No comments

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.