Verify Passwords Match in Windows Powershell
You're looking to compare two secure strings, so you'll need to decrypt them first. Here's an implementation of what you're trying to do:
Write-Host "Hey..!! I am here to compare the password you are entering..."$pwd1 = Read-Host "Passowrd" -AsSecureString$pwd2 = Read-Host "Re-enter Passowrd" -AsSecureString$pwd1_text = [Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR($pwd1))$pwd2_text = [Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR($pwd2))if ($pwd1_text -ceq $pwd2_text) {Write-Host "Passwords matched"} else {Write-Host "Passwords differ"}
and this is where I got that from: http://techibee.com/powershell/compare-secure-strings-entered-through-powershell/422
also possibly relevant: https://www.roelvanlisdonk.nl/2010/03/23/show-password-in-plaintext-by-using-get-credential-in-powershell/