Workaround for PLink Key Issue in Powershell

Posted Saturday, January 14, 2012 in Old JamesCMS Posts

Here's a workaround for scripting with plink. You might run into the issue where plink will ask to verify a ssh key. This will detect it and redirect the question to the console where you can select yes or no, after which the script will rerun the command.

{{Powershell}}
$plinkresults = .\plink.exe -l $username -pw $pt -ssh $phost $pcmd            
if ($plinkresults -eq $null)            
{            
    .\plink.exe -l $username -pw $pt -ssh $phost some command 2>&1            
    $plinkresults = .\plink.exe -l $username -pw $pt -ssh $phost $pcmd            
}