title: Create Azure AD B2C local account user with Powershell New-AzureADUser
body: <p>I'm trying to create a local user in an Azure AD B2C directory which can be used for authentication immediately after creation.</p>
  
  <pre><code>Connect-AzureAD -TenantId $targetB2cTenant
  
  $passwordProfile = New-Object -TypeName Microsoft.Open.AzureAD.Model.PasswordProfile
  $passwordProfile.Password = "Test-User-Password-Here"
  $userName = "TestUser@MyTestB2CTenant.onmicrosoft.com"    
  $signInNames = @(
      (New-Object `
          Microsoft.Open.AzureAD.Model.SignInName `
          -Property @{Type = "userName"; Value = $userName})
  )
  
  $newUser = New-AzureADUser -AccountEnabled $True -DisplayName "testpowershellusercreation" -PasswordProfile $passwordProfile -SignInNames $signInNames -CreationType "LocalAccount"
  
  Disconnect-AzureAD
  </code></pre>
  
  <p>From reading the documentation I need to specify the CreationType parameter as "LocalAccount":</p>
  
  <p><a href="https://docs.microsoft.com/en-us/powershell/module/azuread/new-azureaduser?view=azureadps-2.0" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/powershell/module/azuread/new-azureaduser?view=azureadps-2.0</a></p>
  
  <p><a href="https://stackoverflow.com/q/49034682">Creating a B2C user with MFA that can immediately login</a></p>
  
  <p>However when I run the powershell code I receive the following error:</p>
  
  <pre><code>New-AzureADUser : Error occurred while executing NewUser 
  Code: Request_BadRequest
  Message: One or more properties contains invalid values.
  </code></pre>
  
  <p>This error message is not present when I remove the -CreationType parameter.</p>
  
  <p>What is the correct way to create a local account in a B2C directory using Powershell?</p>