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