This discussion has been locked. The information referenced herein may be inaccurate due to age, software updates, or external references.
You can no longer post new replies to this discussion. If you have a similar question you can start a new discussion in this forum.

New-SwisObject "Object reference not set to an instance of an object"

Hello all,

Working with creating objects in NPM 12.3 and we're running into an issue where we are getting the error in the subject of this post but the node seems to be created. We aren't exactly sure what is causing the error and of course don't want to import over 800 nodes without knowing what this error is doing to our efforts. Does anyone know what would be causing this?

Node type: SNMPv2

NPM version: 12.3

PowerShell version: 5 (Windows 2016)

SNMP information is redacted but present in the node properties variable we are using.

Error Details:

PS C:\Users\MyUser\Desktop> $error[0]|format-list -force

ErrorRecord : Object reference not set to an instance of an

                              object.

WasThrownFromThrowStatement : False

Message : The running command stopped because the preference

                              variable "ErrorActionPreference" or common

                              parameter is set to Stop: Object reference not set

                              to an instance of an object.

Data : {System.Management.Automation.Interpreter.Interprete

dFrameInfo}

InnerException :

TargetSite : Void CheckActionPreference(System.Management.Automat

ion.Language.FunctionContext, System.Exception)

StackTrace :    at System.Management.Automation.ExceptionHandling

Ops.CheckActionPreference(FunctionContext

                              funcContext, Exception exception)

at System.Management.Automation.Interpreter.Actio

nCallInstruction`2.Run(InterpretedFrame frame)

at System.Management.Automation.Interpreter.Enter

TryCatchFinallyInstruction.Run(InterpretedFrame

                              frame)

at System.Management.Automation.Interpreter.Enter

TryCatchFinallyInstruction.Run(InterpretedFrame

                              frame)

at System.Management.Automation.Interpreter.Inter

preter.Run(InterpretedFrame frame)

at System.Management.Automation.Interpreter.Light

Lambda.RunVoid1[T0](T0 arg0)

at System.Management.Automation.DlrScriptCommandP

rocessor.RunClause(Action`1 clause, Object

                              dollarUnderbar, Object inputToProcess)

--- End of stack trace from previous location where

                              exception was thrown ---

at System.Runtime.ExceptionServices.ExceptionDisp

atchInfo.Throw()

at System.Management.Automation.Internal.Pipeline

Processor.SynchronousExecuteEnumerate(Object input)

at System.Management.Automation.Runspaces.LocalPi

peline.InvokeHelper()

at System.Management.Automation.Runspaces.LocalPi

peline.InvokeThreadProc()

HelpLink :

Source : System.Management.Automation

HResult : -2146233087

PS C:\Users\MyUser\Desktop> $PSVersionTable

Name Value

---- -----

PSVersion 5.1.14393.2248

PSEdition Desktop

PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}

BuildVersion 10.0.14393.2248

CLRVersion 4.0.30319.42000

WSManStackVersion 3.0

PSRemotingProtocolVersion 2.3

SerializationVersion 1.1.0.1

PS C:\Users\MyUser\Desktop> $targetNodeProps

Name Value

---- -----

SNMPVersion 2

ObjectSubType SNMP

SNMPV3PrivMethod

PollInterval 150

Status 1

Allow64BitCounters True

SNMPV3Username

BufferBgMissToday 4

StatusLED Up.gif

Contact

IOSVersion 15.0(2)SE11, RELEASE SOFTWARE (fc3)

RWSNMPV3PrivKeyIsPwd

RediscoveryInterval 120

RWSNMPV3PrivMethod

BufferBgMissThisHour 0

BufferMdMissThisHour 0

Community

NodeDescription Cisco IOS Software, C3750E Software (C3750E-UNIV...

RWSNMPV3AuthMethod

Location

SysObjectID 1.3.6.1.4.1.9.1.516

VendorIcon 9.gif

DynamicIP False

Caption <Redacted>

Severity 0

EntityType Orion.Nodes

IPAddressType IPv4

RWCommunity

IOSImage C3750E-UNIVERSALK9-M

BufferLgMissThisHour 0

External False

RWSNMPV3AuthKey

BufferNoMemToday 0

BufferHgMissToday 965

EngineID 1

StatCollection 5

BufferNoMemThisHour 0

SNMPV3AuthKey

BufferSmMissThisHour 0

CMTS N

BufferHgMissThisHour 5

GroupStatus Up.gif

SNMPV3AuthMethod

DNS

IPAddressGUID 0100080a-0000-0000-0000-000000000000

RWSNMPV3PrivKey

MachineType Catalyst 37xx Stack

LastSystemUpTimePollUtc 6/20/2018 4:04:19 PM

RWSNMPV3Context

SNMPV3PrivKeyIsPwd

TotalMemory 1.963532E+08

BufferMdMissToday 4

RWSNMPV3Username

SNMPV3Context

BufferLgMissToday 0

SNMPV3PrivKey

IPAddress 10.8.0.1

RWSNMPV3AuthKeyIsPwd

SNMPV3AuthKeyIsPwd

AgentPort 161

SysName

BufferSmMissToday 0

ChildStatus 1

StatusDescription Node status is Up.

Vendor Cisco

pastedImage_0.png

  • I put together a PowerShell script to try to reproduce your issue.  I tried to initialize $targetNodeProps with values that were as close as possible to the output you shared.  This runs without error for me.  If you hard-code the values in the creation of $targetNodeProps, do you still encounter the error?  Obviously, you'll need to set the correct server, username, and password for your environment.

    if ( (Get-PSSnapin -Name SwisSnapin -ErrorAction SilentlyContinue) -eq $null )
    {
        Add-PsSnapin SwisSnapin
    }

    $OrionServer = 'myserver.mydomain.local'
    $Username = 'admin'
    $Password = 'secretpassword'

    $target = Connect-Swis -Hostname $OrionServer -Username $Username -Password $Password

    $targetNodeProps = @{
        SNMPVersion = 2;
        ObjectSubType = 'SNMP';
        SNMPV3PrivMethod = '';
        PollInterval = 150;
        Status = 1;
        Allow64BitCounters = $True;
        SNMPV3Username = '';
        BufferBgMissToday = 4;
        StatusLED = 'Up.gif';
        Contact = '';
        IOSVersion = '15.0(2)SE11, RELEASE SOFTWARE (fc3)';
        RWSNMPV3PrivKeyIsPwd = [bool]$null;
        RediscoveryInterval = 120;
        RWSNMPV3PrivMethod = '';
        BufferBgMissThisHour = 0;
        BufferMdMissThisHour = 0;
        Community = '';
        NodeDescription = 'Cisco IOS Software, C3750E Software (C3750E-UNIV...';
        RWSNMPV3AuthMethod = '';
        Location = '';
        SysObjectID = '1.3.6.1.4.1.9.1.516';
        VendorIcon = '9.gif';
        DynamicIP = $False;
        Caption = '<Redacted>';
        Severity = 0;
        EntityType = 'Orion.Nodes';
        IPAddressType = 'IPv4';
        RWCommunity = '';
        IOSImage = 'C3750E-UNIVERSALK9-M';
        BufferLgMissThisHour = 0;
        External = $False;
        RWSNMPV3AuthKey = '';
        BufferNoMemToday = 0;
        BufferHgMissToday = 965;
        EngineID = 1;
        StatCollection = 5;
        BufferNoMemThisHour = 0;
        SNMPV3AuthKey = '';
        BufferSmMissThisHour = 0;
        CMTS = 'N';
        BufferHgMissThisHour = 5;
        GroupStatus = 'Up.gif';
        SNMPV3AuthMethod = '';
        DNS = '';
        IPAddressGUID = '0100080a-0000-0000-0000-000000000000';
        RWSNMPV3PrivKey = '';
        MachineType = 'Catalyst 37xx Stack';
        LastSystemUpTimePollUtc = [DateTime]::Parse('6/20/2018 4:04:19 PM');
        RWSNMPV3Context = '';
        SNMPV3PrivKeyIsPwd = [bool]$null;
        TotalMemory = 196353200;
        BufferMdMissToday = 4;
        RWSNMPV3Username = '';
        SNMPV3Context = '';
        BufferLgMissToday = 0;
        SNMPV3PrivKey = '';
        IPAddress = '10.8.0.1';
        RWSNMPV3AuthKeyIsPwd = [bool]$null;
        SNMPV3AuthKeyIsPwd = [bool]$null;
        AgentPort = 161;
        SysName = '';
        BufferSmMissToday = 0;
        ChildStatus = 1;
        StatusDescription = 'Node status is Up.';
        Vendor = 'Cisco';
    }

    $targetNodeProps

    $newUri = New-SwisObject $target -EntityType 'Orion.Nodes' -Properties $targetNodeProps
    $newNode = Get-SwisObject $target $newUri

    $newNode
  • You might also want to check the Orion.InformationService.log file on your Orion Server.  Run your script to cause the error, then open this file:

    C:\ProgramData\SolarWinds\InformationService\v3.0\Orion.InformationService.log

    Locate the exception near the end of the file, and post it here.

  • Just to close the loop we had to just do mass node discovery and data entry as this was time sensitive on our end so I did not get the chance to go through the troubleshooting efforts you suggested. But thank you very much for the suggestions and I'll try to remember them the next time I run into an error. emoticons_grin.png