728x90

$UserName = '도메인명\계정'
$Password = "비밀번호"
$Domain = $env:USERDOMAIN

Add-Type -AssemblyName System.DirectoryServices.AccountManagement
$ct = [System.DirectoryServices.AccountManagement.ContextType]::Domain
$pc = New-Object System.DirectoryServices.AccountManagement.PrincipalContext $ct,$Domain
$pc.ValidateCredentials($UserName,$Password)

 

결과값(암호가 맞을 경우)

True

결과값(암호가 틀릴 경우)

False

728x90

+ Recent posts