Microsoft Virtualization Discussions

Invoke-NaSsh : Auth fail

TIM_RUFUS

Hi,

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

$SrcFilerName="nas01"

$DstFilerName="nas02"

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

1 ACCEPTED SOLUTION

cknight

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

Connect-NaController 10.61.167.60 -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 10.61.167.60 -Credential root -ErrorAction SilentlyContinue -Transient

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

View solution in original post

1 REPLY 1

cknight

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

Connect-NaController 10.61.167.60 -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 10.61.167.60 -Credential root -ErrorAction SilentlyContinue -Transient

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

View solution in original post

Announcements
NetApp on Discord Image

We're on Discord, are you?

Live Chat, Watch Parties, and More!

Explore Banner

Meet Explore, NetApp’s digital sales platform

Engage digitally throughout the sales process, from product discovery to configuration, and handle all your post-purchase needs.

NetApp Insights to Action
I2A Banner
Public