Add-Type -AssemblyName System.DirectoryServices.AccountManagement
$DS = New-Object System.DirectoryServices.AccountManagement.PrincipalContext('domain')
$DS.ValidateCredentials($UserName, $Password)
Attempts to authenticate against domain controller and return true or false if it was able to authenticate successfully.
PS C:\> $user = 'user01' >> $password = 'Password01' >> Add-Type -AssemblyName System.DirectoryServices.AccountManagement >> $DS = New-Object System.DirectoryServices.AccountManagement.PrincipalContext('domain') >> $DS.ValidateCredentials($UserName, $Password) True