0

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)
$domain.name
$global:Creds = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $password
1
  • Where do you execute this command. On a DC?
    – SimonS
    Oct 12, 2015 at 12:02

1 Answer 1

1

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?

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .