<#
.Synopsis
Verify Active Directory credentials
.DESCRIPTION
This function takes a user name and a password as input and will verify if the combination is correct. The function returns a boolean based on the result.
.NOTES
Name: Test-ADCredential
Author: Jaap Brasser
Version: 1.0
DateUpdated: 2013-05-10
.PARAMETER UserName
The samaccountname of the Active Directory user account
.PARAMETER Password
The password of the Active Directory user account
.EXAMPLE
Test-ADCredential -username jaapbrasser -password Secret01
Description:
Verifies if the username and password provided are correct, returning either true or false based on the result
#>
function Test-ADCredential {
[CmdletBinding()]
Param
(
[string]$UserName,
[string]$Password
)
if (!($UserName) -or !($Password)) {
Write-Warning 'Test-ADCredential: Please specify both user name and password'
} else {
Add-Type -AssemblyName System.DirectoryServices.AccountManagement
$DS = New-Object System.DirectoryServices.AccountManagement.PrincipalContext('domain')
$DS.ValidateCredentials($UserName, $Password)
}
}
Test-ADCredential "username" "defaultpass"
测试AD用户密码
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
推荐阅读更多精彩内容
- 提示用户输入用户名,然后再提示输入密码,如果用户名是“admin”并且密码是“88888”,则提示正确,否则,如果...
- 在完成iOS开发,准备进行发布之前,我们都希望App能在周围的朋友之间先进行测试,提提意见,修改完善之后再发布到A...
- 题目 提示用户输入用户名,然后再提示输入密码,如果用户名是“admin”并且密码是“88888”,则提示正确,否则...
- 今天听课的最大感受就是:1硬科学对人类思维的构造的重要性,2学习时要谦逊,stay foolish,stay hu...