PowerShell Local Account Password Check

        Check Password on a Local Account on Remote Machine
        Sometimes you need to check a password on remote machne
        Requires rights on the remote machine.     

# Command Executed on Remote Machine


    #Paramater for inbound Data

    Add-Type -AssemblyName System.DirectoryServices.AccountManagement
    $obj = New-Object System.DirectoryServices.AccountManagement.PrincipalContext('machine',$Env:Computername)

    $PasswordResetResult=$obj.ValidateCredentials($PassedArray[0], $PassedArray[1])
        $PasswordResetResultText="Account / Password Check Passed"
        $PasswordResetResultText="Account / Password Check Failed"
    return $PasswordResetResultText

#Decalre Array to Pass

#Get Input From Users
$PassedArray+= Read-host "Enter Accounts to Check"
$PassedArray+= Read-Host "Enter Password"
$ServerName=   Read-host "Enter Server Name"

#Execute Command 
Invoke-Command $ServerName -ScriptBlock $TestPassword -ArgumentList @(,$PassedArray) 

2020 | Scott W. Head  |  Sr. Systems Admin | Certified Microsoft Windows Server Administrator