PowerShell – validation安全证书

不知道为什么这不起作用。 我已经看到其他人也这样做,但我使用安全的信用,不知道这是否与它有关。 $ domain.name是空的

$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 

您正在将一个SecureString发送到System.DirectoryServices.DirectoryEntry,但后者希望以明文formsinput密码。 另外,你在$ password和$ global之间混合:Password,你确定你使用的是正确的吗?