Quick and Easy Password Generator

This is a quick and easy password/random character generator. It returns random numbers between 33 and 126 and converts the number to the corresponding ASCII character.

$password = [string]::Empty
1..32 | ForEach-Object {
    $password += [char]$(33..126 | Get-Random)
}
Test AD User Credentials
Add-Type -AssemblyName System.DirectoryServices.AccountManagement
$DS = New-Object System.DirectoryServices.AccountManagement.PrincipalContext('domain')
$DS.ValidateCredentials($UserName, $Password)
Details
Attempts to authenticate against domain controller and return true or false if it was able to authenticate successfully.

Example
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
  |