# Verify AD User Password

**URL:** <https://forums.powershell.org/t/verify-ad-user-password/17834>\
**Category:** PowerShell Help\
**Created:** [October 29, 2021, 7:03am UTC](https://forums.powershell.org/t/verify-ad-user-password/17834 "2021-10-29T07:03:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mervin16](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/mervin16/32/1796_2.png) [@mervin16](https://forums.powershell.org/u/mervin16)\
**Post date:** [October 29, 2021, 7:03am UTC](https://forums.powershell.org/t/verify-ad-user-password/17834/1 "2021-10-29T07:03:33Z")

</div>

I understand that no secure application has the ability to retrieve a password by using a mere script, but I was wondering if it’s possible to at least verify if an entered password is correct using PowerShell.

I need to build a script that will allow a user to change his AD password, but for that to be possible, he/she needs to enter his current password. I will then perform a check to see if the current entered password is correct before proceeding.

I tried to verify the current attributes that a `Get-ADUser` can return, but i can’t find anything useful to this.

Can someone please help me out?

---

<div class="post-metadata">

**Author:** ![krzydoug](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/krzydoug/32/1008_2.png) [@krzydoug](https://forums.powershell.org/u/krzydoug)\
**Post date:** [October 29, 2021, 9:01am UTC](https://forums.powershell.org/t/verify-ad-user-password/17834/2 "2021-10-29T09:01:01Z")

</div>

You can use this code snippet to verify the user credentials.

```auto
# Validate credentials
[System.Reflection.Assembly]::LoadWithPartialName("System.DirectoryServices.AccountManagement")
$principalContext = New-Object System.DirectoryServices.AccountManagement.PrincipalContext([System.DirectoryServices.AccountManagement.ContextType]::Domain, '<yourdomain>')
$principalContext.ValidateCredentials('<user>', '<password>')

```

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:20pm UTC](https://forums.powershell.org/t/verify-ad-user-password/17834/3 "2024-05-16T20:20:38Z")

</div>

Closed on May 16, 2024, 8:20pm UTC


