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

PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,328 questions
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
20,629 questions
{count} votes

1 answer

Sort by: Most helpful
  1. akinbade abiola 9,390 Reputation points
    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