Powershell ADUser 命令不与 AD 同步

时间:2021-06-09 20:02:59

标签: powershell

下面的文字是我尝试使用导入模块 ActiveDirectory

Import-Module ActiveDirectory

#Get-Command New-ADUser -Syntax

$firstName = Read-Host -Prompt "Please enter the first name"
$lastName = Read-Host -Prompt "Please enter the last name"


$UserParams = @{
    Name = "$firstName $lastName"
    GivenName = $firstName
    Surname = $lastName 
    UserPrincipalName = "$firstName.lastname"
    EmailAddress = "$firstName.$lastName@<domain>"
    ChangePasswordAtLogon = 1 
    Enabled = 1 
    StreetAddress = "<info>" 
    Office = "<info>" 
    State = "<info>" 
    PostalCode = "<info>" 
    Country = "<info>" 
    Path = "OU=External,OU=Workers,OU=Group,DC=<domain>,DC=com" 
}
New-ADUser @UserParams

运行时出现此错误

+ New-ADUser @UserParams
+ ~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (CN=test user,OU...=<domain>,DC=com:String) [New-ADUser], ADException
    + FullyQualifiedErrorId : ActiveDirectoryServer:<port>,Microsoft.ActiveDirectory.Management.Commands.NewADUser

路径不正确?我知道它应该是正确的,因为我是从字符串属性编辑器中的 distinctName 复制的。

0 个答案:

没有答案
相关问题