As of now I tried using Wsman commands and it succeed in most cases.
Here is the sample code for that:
$Password = ConvertTo-SecureString $password -AsPlainText -Force
$Username = $username
$Cred = New-Object System.Management.Automation.PSCredential ($Username, $Password)
$Session = New-PSSession -ComputerName $Target.ip -Credential $Cred
throw "Access Denied. Invalid credentials."