Microsoft Virtualization Discussions

how to refer to zapi error code by name

nthakur

Get-NaControllerError prints all zapi error codes. If I want to compare the error code in my script, how do I refer to the error code by name? For example, $ErrorNumber -eq $EONTAP_EPERM instead of $ErrorNumber -eq 1.

PS C:\Toolkit\1.7.0> Get-NaControllerError

Code Name                    Description

---- ----                    -----------

    1 EONTAPI_EPERM           Operation not permitted

    2 EONTAPI_ENOENT          No such file or directory

    3 EONTAPI_ESRCH           No such process

    4 EONTAPI_EINTR           Interrupted system call

    5 EONTAPI_EIO             Input/Output error

Thanks,

neelesh

4 REPLIES 4

cknight

Not sure I understand the question, but the cmdlet does accept arguments such as the name (which could be a variable):

PS C:\> Get-NaControllerError -Name EONTAPI_EPERM


Code Name                                     Description

---- ----                                     -----------

   1 EONTAPI_EPERM                            Operation not permitted

PS C:\> Get-NaControllerError -Code 1

Code Name                                     Description

---- ----                                     -----------

   1 EONTAPI_EPERM                            Operation not permitted

nthakur

Thanks for the reply. I am looking for a way to use EONTAPI_* inside my script. Currently I have:

# at the top

$E_JOB_EXISTS = 18380

# somewhere down in the script

if ($errorNumber -eq $E_JOB_EXISTS)
{

Is there a better way to do this using a builtin EONTAPI_JOB_EXISTS variable?

Thanks.

cknight

There aren't built-in variables for error codes, but you can do this:

if ($errorNumber -eq (Get-NaControllerError EONTAPI_EEXIST).Code) {...}

nthakur

Ok. Thanks.

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