Accepted Solution

Invoke-NaSsh : Auth fail


How would I write a script that covers typos in authentication?



Add-NaCredential $SrcFilerName

Add-NaCredential $DstFilerName

Invoke-NaSsh -name $SrcFilerName "hostname"

Invoke-NaSsh -name $DstFilerName "hostname"


How can I exit the script if a typo is made in either of authentication processes?

If incorrect credentials are supplied the above invoke-nassh cmds errors with:-

Invoke-NaSsh : Auth fail

Thanks, Tim

Re: Invoke-NaSsh : Auth fail

Hi, Tim.  The simplest way is probably to test the credentials using Connect-NaController:

Connect-NaController -Credential root -ErrorAction Stop -Transient

If an error occurs, the script will abort.

If you want more control over the error handling, something like this might work:

$c = Connect-NaController -Credential root -ErrorAction SilentlyContinue -Transient

if ($c -EQ $null) { Write-Host "Connection failed." }