Microsoft Virtualization Discussions

trapping errors on Connect-NaController

paulshearer
2,461 Views

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
2,461 Views

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 }

Public