"Access is denied" aparece no fluxo de erros. Você pode usar os operadores de redirecionamento do Windows PowerShell , por exemplo, da seguinte maneira:
$aux = . plink -batch -ssh $defUser@$srv -pw $defPassword -m $executeCommandFile *>&1
if ( $aux -match '^Access.*denied' ) {
### the specified string found: use different $defPassword
} else {
### success
$aux ### show plink results
}
Observe que 2>&1 poderia ser suficiente:
*>&1sends all output types (*) to the success output stream;2>&1sends errors (2) and success output (1) to the success output stream.