cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Level 12

Create Container with Parent in Powershell

Jump to solution

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

0 Kudos
1 Solution

Accepted Solutions
Level 12

Re: Create Container with Parent in Powershell

Jump to solution

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.

View solution in original post

4 Replies
Level 12

Re: Create Container with Parent in Powershell

Jump to solution

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.

View solution in original post

Highlighted
Level 9

Re: Create Container with Parent in Powershell

Jump to solution

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

0 Kudos
Highlighted
Level 12

Re: Create Container with Parent in Powershell

Jump to solution

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.

Highlighted
Level 12

Re: Create Container with Parent in Powershell

Jump to solution

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