我可以成功使用Powershell来判断用户是否在Active Directory中进行身份validation:
Function Test-ADAuthentication { param($username,$password) (new-object directoryservices.directoryentry "",$username,$password).psbase.name -ne $null } Test-ADAuthentication "test" "Password1"
但是,我不能为了我的生活弄清楚如何:
怎么能这样呢?
可以通过运行一个进程来testing证书。 下面的例子,
Start-Process -FilePath cmd.exe /c -Credential (Get-Credential -UserName $username -Message 'Test Credential')
或者干脆:
Start-Process -FilePath cmd.exe /c -Credential (Get-Credential)
您将看到提示input密码。 如果您需要从string读取密码(错误的做法),则需要事先初始化凭证对象。 有关该方法的更多细节可以在帮助中find。
Get-Help Get-Credential