【发布时间】:2018-03-14 12:43:10
【问题描述】:
我正在尝试在 Azure AD B2C 目录中创建一个本地用户,该用户可在创建后立即用于身份验证。
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
通过阅读文档,我需要将 CreationType 参数指定为“LocalAccount”:
https://docs.microsoft.com/en-us/powershell/module/azuread/new-azureaduser?view=azureadps-2.0
Creating a B2C user with MFA that can immediately login
但是,当我运行 powershell 代码时,我收到以下错误:
New-AzureADUser : Error occurred while executing NewUser
Code: Request_BadRequest
Message: One or more properties contains invalid values.
当我删除 -CreationType 参数时,此错误消息不存在。
使用 Powershell 在 B2C 目录中创建本地帐户的正确方法是什么?
【问题讨论】:
标签: powershell azure azure-ad-b2c azure-ad-graph-api