NetApp Community Update
This site will enter Read Only mode on July 23 as we prepare to move to a new platform.
You will still be able to view content, but posting and replying will be temporarily disabled.
To learn more, please review the information in this blog post.

Microsoft Virtualization Discussions

trapping errors on Connect-NaController

paulshearer
3,332 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
3,332 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