With PowerShell you can easily verify a password domain account. with other words, you can bind script logic to passwords maintained in the Active Directory.
Below a a short piece of PowerShell code to send a password to the Active Directory and get back a value $true if the password is correct, else $false.
$UserDomain = $env:USERDOMAIN
$UserName = $env:USERNAME
$Password = Read-Host -Prompt "Enter password"
Add-Type -AssemblyName System.DirectoryServices.AccountManagement
$ContextType = [System.DirectoryServices.AccountManagement.ContextType]::Domain
$PrincipalContext = [System.DirectoryServices.AccountManagement.PrincipalContext]::new($ContextType, $UserDomain)
You can easily connect to the Active Directory and ask for a password validation with PowerShell.
I really like to hear what you have to say about this article:
- Was this article helpful for you or do you have any questions?
- Do you have additions, suggestions or any other ideas?
- Just let me know by leaving a comment below.
Thank you for spending some time at my site and in my blog. I hope you come to visit again soon 😉