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
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,
You can find powershell samples for Groups manipulation @C:\Program Files (x86)\SolarWinds\Orion SDK\Samples\PowerShell\Groups.ps1 (Your SDK installed directory)
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
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
# group ID
$groupId,
<Name>Up Devices</Name>
<Definition>swis://xxx-xxxx-xxxx-01./Orion/Orion.Nodes/NodeID=1</Definition>
=========================================================================
#
# 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" @(
([xml]@(
"<ArrayOfMemberDefinitionInfo xmlns='http://schemas.solarwinds.com/2008/Orion'>",
[string]($members |% {
"<MemberDefinitionInfo><Name>$($_.Name)</Name><Definition>$($_.Definition)</Definition></MemberDefinitionInfo>"
}
),
"</ArrayOfMemberDefinitionInfo>"
)).DocumentElement
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.
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?
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.