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.

add node to container powershell

Hello Guys,

I can't find how to add a node to group/container with powershell,

i have the uri of the node and for the group but i don't know how to merge them,

Please help with simple powershell code

Thanks

  • Hi,

    You can find powershell samples for Groups manipulation @"C:\Program Files (x86)\SolarWinds\Orion SDK\Samples\PowerShell\Groups.ps1" (Your SDK installed directory)

  • Thanks

    i saw the folder and can't get it out from the script-

    the "GroupID" in the example is for a new group

    i want to add members to an existing group

    if you know how to do it from the example there please cut and paste the right code,

    any help is welcome

    thanks

  • Thanks

    I found it

    the groupID is int32 paremeter, set the id and now it's fine-

    if anybody needs it, here's the code
    :

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

        # group ID ## int32 number

        17,

        # group member to add

        ([xml]"

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

             <Name>NodeName</Name>

             <Definition>$NodeUri</Definition>

           </MemberDefinitionInfo>"

        ).DocumentElement

      ) | Out-Null

  • Hi,

    Provided the code to add one or more members to a group. Here the you need to replace the bolded with groupid and uri / condition.

    # ADDING A NEW GROUP MEMBER

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

        # group ID

        $groupId,

        # group member to add

        ([xml]"

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

             <Name>Up Devices</Name>

             <Definition>swis://xxx-xxxx-xxxx-01./Orion/Orion.Nodes/NodeID=1</Definition>

           </MemberDefinitionInfo>"

        ).DocumentElement

      ) | Out-Null

    =========================================================================

    #

    # ADDING MULTIPLE NEW GROUP MEMBERS

    #

    $members = @(

      @{ Name = "Down Devices"; Definition = "filter:/Orion.Nodes[Status=2]" },

      @{ Name = "Unreachable Devices"; Definition = "filter:/Orion.Nodes[Status=12]" }

    )

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

        # group ID

        $groupId,

        # group member to add

        ([xml]@(

           "<ArrayOfMemberDefinitionInfo xmlns='http://schemas.solarwinds.com/2008/Orion'>",

           [string]($members |% {

             "<MemberDefinitionInfo><Name>$($_.Name)</Name><Definition>$($_.Definition)</Definition></MemberDefinitionInfo>"

             }

           ),

           "</ArrayOfMemberDefinitionInfo>"

        )).DocumentElement

      ) | Out-Null

  • Do you know how to find the ID of a group/Container?

  • get-swisdata $swis "SELECT ContainerID, Name, Owner, Frequency, StatusCalculator, RollupType, IsDeleted, PollingEnabled, LastChanged FROM Orion.Container where Name = 'Sample Powershell Group'"

    Modify the select statement to select only ContainerID in case you need only container ID.

    You can have a look at the documentation @"C:\Program Files (x86)\SolarWinds\Orion SDK\Documentation". It has more information on SWIS and SWQL.

  • Thanks

    where did you find that?

    i search for "container" in the whole pdf and has not found any results

    my SDK is 1.9

    mayber you have a different file? where can i find it please?

    thanks

  • It is generic documentation to help you understand SDK. You can modify or create queries based on your need. There are tools like swql studio where you can try out queries and samples.

  • can you please help me with some links?

    thanks again

  • Have a look at C:\Program Files (x86)\SolarWinds\Orion SDK\Documentation\Orion SDK.pdf. It has all the information you need with examples (It is not specific to containers but has information on how to get specific data, invoke verb and much more)