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.

Create Container with Parent in Powershell

I can't seem to get a script of mine working, can someone help me figure this out?  I'm still pretty new to using the API and I maybe touch PowerShell twice a year, so this is kinda new territory for me.  Whenever I try to run it, it asks me for the EntityName, so I already know it doesn't work like it does in my head.

Here's the script:

param(

[string]$parentID,

[string]$name,

[int]$statCalc)

#Credentials should be passed from outside in a variable called $cred.

# Connect to SWIS

$hostname = "localhost"

$swis = Connect-Swis -Credential $cred -host $hostname

# Define Properties

$newContainerProps = @{

    parentID = $parentID;

    Name = $name;

statusCalculator = $statCalc;

    # === default values ===

    frequency = 60;

    owner = 'CORE'

    Description = 'Active-Passive Pair of Service Monitors'

    pollingEnabled = 'TRUE'

}

#Create the Container

Invoke-SwisVerb $swis -Verb createContainerWithParent -Arguments $newContainerProps

  • I answered my own question by finding the samples page on GitHub and looking at the Groups one for reference.

    OrionSDK/Samples/PowerShell at master · solarwinds/OrionSDK · GitHub

    Hope this helps someone else equally new to this stuff.

  • Did you ever try and get the memberDefinitions parameter in too, im struggling to get that in. I can do it manually via the SWIS Studio but not in my script

  • Sorry for the months-late response.

    I eventually did, but it's clunky and kind of a pain since it just creates a bare-bones dynamic query.  I'll upload what I've got now and link you.  Also I'm cringing hard at my old script, so it's pretty cool to see some progress.

  • Just kidding, content exchange appears to be broken today.  Here's what I did, hope this helps or that you already got it working:

                        Invoke-SwisVerb $swis "Orion.Container" "AddDefinition" @(

                            $container,

                            #-----------Dynamic Query Below

                            ([xml]"

                               <MemberDefinitionInfo xmlns='http://schemas.solarwinds.com/2008/Orion'>

                                 <Name>ActPas Nodes</Name>

                                 <Definition>filter:/Orion.APM.Application[ApplicationId=$pairMemberAppId]</Definition>

                               </MemberDefinitionInfo>"

                            ).DocumentElement

                            #----------End of Dynamic Query

                          ) | Out-Null