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.

SolarWinds SDK Powershell WMI Add script

I'm having trouble with adding nodes using powershell.  I've started with the CRUD.AddWMINode.ps1 script and am able to get all the information to go in properly but the authenticated user is not set on the node.

I think I've narrowed it down to the user definitions.  I came to this conclusion by running the commands separately and there are 3 values that return for my user name, 2 of which are owned by "Orion".  I've tried setting the ID number for the variable but that didn't make a difference.

$credentialName = "ValidCredentialName"

$credentialId = Get-SwisData $swis "SELECT ID FROM Orion.Credential where Name = '$credentialName'"

I've seen people have similar issues and it doesn't seem to have been resolved.  I'm hoping someone can tell if the issue is in the script or something miss configured in the app.

Thanks in advance.

Charlie

  • Hi,

    when I need something like this my script looks like this.

    $username = "YOURUSERNAME"

    $SecurePassword = ConvertTo-SecureString -AsPlainText -Force -String 'YOURPASSWORD'

    $cred = New-Object -typename System.Management.Automation.PSCredential -argumentlist $username, $Securepassword

    $SwisConnection = Connect-Swis -Hostname $hostname -Credential $cred

    #then I use a variable for the SQL-command because sometimes they are very long

    #For Example SQL-Statement to get Attributes of a custom property

    $customproperty = "devicetype"

    $YOURVARSQL = @"

    SELECT Table, Field, DataType, MaxLength, StorageMethod, Description, TargetEntity, Mandatory, Default

    FROM Orion.CustomProperty  WHERE Field = '$($customproperty)'

    "@

    #Note I am new to Powershell but I figured out that sometime you have to parse a variable to get the output as a string or something like this. Please correct me emoticons_grin.png So for that use $($variablename) like above in the SQL-command.

    $YOURVAR = Get-SwisData -SwisConnection $SwisConnection -Query $YOURVARSQL

    Hope this helps you emoticons_grin.png