Open Yvand opened 1 year ago
Can you verify that it throws the same error if you use the fully qualified domain name instead of NetBios name, eg user@domain.com
@johlju I confirm it works fine if the username is in format user@domain.com
Safer solution might be to pickup username with $Credential.GetNetworkCredential().UserName
this will only have the username. and not domain part if this was supplied in the credential object.
` $params = @{ TypeName = 'System.DirectoryServices.DirectoryEntry' ArgumentList = @( $DomainName, $Credential.GetNetworkCredential().UserName, $Credential.GetNetworkCredential().password ) ErrorAction = 'Stop' } $searchRoot = New-Object @params $searcher.SearchRoot = $searchRoot
`
Problem description
Scenario: VM is in a workgroup and wants to join an AD domain for the 1st time: It successfully joins the AD domain, but DSC throws the following error:
Exception calling "FindOne" with "0" argument(s): "The user name or password is incorrect."
This is thrown by
DirectorySearcher.FindOne()
infunction Get-ADSIComputer
: https://github.com/dsccommunity/ComputerManagementDsc/blob/fcff2e040bf8162f8138eb08612fde3e3c60ef42/source/DSCResources/DSC_Computer/DSC_Computer.psm1#L745Verbose logs
DSC configuration
Suggested solution
I did not investigate the exact reason of the error message "The user name or password is incorrect.", but credentials are valid since VM joins the AD domain successfully.
A possible simple workaround would be to add a try catch:
Operating system the target node is running
PowerShell version and build the target node is running
ComputerManagementDsc version