Microsoft Virtualization Discussions

trapping errors on Connect-NaController

paulshearer

Hello All,

I'm somewhat new to powershell and the DataOntap module. Could
someone provide some guidance on trapping errors on
Connect-NaController. Basically
if there is an authentication or communication issue I was to write out a
cleaner error to the screen and prompt the user to re-enter their information.

import-module C:\Windows\System32\WindowsPowerShell\v1.0\Modules\DataONTAP

 

$user = Read-Host "Enter Netapp User ID"

$password = (Read-Host -assecurestring "Enter Netapp Password")

$Netapp_IP = Read-Host "Enter Netapp IP Address"

$cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $user,$password

$NaController = (Connect-NaController $Netapp_IP  -Credential $cred)

1 REPLY 1

cknight

Hi, Paul.  Try something along these lines:

$NaController = Connect-NaController dunn -Credential root -ErrorAction SilentlyContinue

if ($NaController -eq $null) { Write-Host $Error[0].Exception.Message }

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