Not sure why this is not working. I've seen other people do the same but I'm using secure creds and not sure if that has something to do with it. The $domain.name is coming back empty

$global:username=read-host "Domain Admin User (domain\username)" 
read-host "Domain Admin Password" -assecurestring | convertfrom-securestring | out-file C:\windows\temp\ap.txt
$global:Password=cat c:\windows\temp\ap.txt | Convertto-SecureString 
$LDAPCON="LDAP://" + (Convert-ToDistinguishedName $domainfqdn)
$domain = New-Object System.DirectoryServices.DirectoryEntry($LDAPCON,$username,$password)
$global:Creds = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $password
  • Where do you execute this command. On a DC? – SimonS Oct 12 '15 at 12:02

You are sending a SecureString to System.DirectoryServices.DirectoryEntry, however the latter expects the password in clear text. Also, you are mixing between $password and $global:Password, are you sure you are using the correct one?

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.