DSC资源xADUser无法登录到服务器

时间:2017-02-07 21:46:47

标签: powershell powershell-dsc

我在域控制器上运行DSC脚本以添加用户。在我的情况下,xADUser失败并出现以下错误。

PowerShell DSC resource MSFT_xADUser  failed to execute Test-TargetResource functionality with 
error message: 
Either the target name is incorrect or the server has 
rejected the client credentials. 

这是添加用户的脚本部分。

foreach ($svcAcct in  $srvcAccounts){
            xADUser ("AddSvcAcct-" + $svcAcct){
                DomainName = $DomainName
                UserName = $svcAcct
                Password = $DomainAdminCredential
                Ensure = "Present"
                CommonName = $svcAcct
                UserPrincipalName = ("{0}@{1}" -f $svcAcct, $DomainName)
                DisplayName = "$svcAcct"
                CannotChangePassword = $true
                DependsOn = "[xADDomain]CreateForest"
                Description = "SharePoint Service Account"
                DomainAdministratorCredential = $DomainAdminCredential
                Enabled = $true
                PasswordAuthentication = "Default"
                PasswordNeverExpires = $true
                DomainController = "DC1"
            }

        }

1 个答案:

答案 0 :(得分:0)

由于我在域控制器上运行此代码,因此通过删除DomainAdministratorCredential和其他可选参数来简化资源声明,然后它就可以工作。

xADUser ("AddSvcAcct-" + $svcAcct){
  DomainName = $DomainName
  UserName = $svcAcct
  Password = $DomainUserCredential
  Ensure = "Present"
  PasswordNeverExpires = $true
  Path = $ou
  DependsOn = @("[xADOrganizationalUnit]SrvcAcctOUCreate")
}