Hi
Very new to the PS & API
I like to duplicate from the GUI
Group name ALB
filter is CP Site = ALB
Do you want to enumerate the members of the existing group or do you want to build a new Group containing Dynamic Queries?
Yes do you have something close to that?
They are two different requests.
Enumerating group membership is (relatively) easy. There's a custom query that does something very similar.
If you wanted to build a group with a single dynamic query inside it, you'd use the CreateContainer verb under the Orion.Container entity. An example is published at OrionSDK/Groups.ps1 at master · solarwinds/OrionSDK · GitHub.
CreateContainer
Orion.Container
This is what I came up with for your request
# Build a group with a dynamic query member# Variables# Group Name and Description$GroupName = 'ALB'$GroupDescription = 'ALB Group - build by PowerShell'# Dynamic Query Name and Description$QueryName = "DQ_Custom Property 'Site' matches 'ALB'"$QueryDefinition = "filter:/Orion.Nodes[CustomProperties.Site='ALB']"# Build the Definition for the Dynamic Query$MemberDefinitions = [xml]( @" $( $QueryName ) $( $QueryDefinition )"@ ) $( $Query1Name ) $( $Query1Definition ) $( $Query2Name ) $( $Query2Definition )"@ )#># Connect to SolarWinds Information Service$SwisConnection = Connect-Swis -Hostname "orion.demo.lab" -Username 'YourUsername' -Password 'YourPassword'# Call the verb# Arguments are as follows:# Name of the Group# "Owner" of the group - this is almost always be "Core"# Time to poll for status changes (in seconds)# Status calculation type: 0 = Mixed [default], 1 = show worst, 2 = show best# Description for the group# Polling enabled "true" / "false"# Member Definitions from above converted to a 'document' from raw XML# Make the call and store the response (it includes the group ID$BuildGroupResponse = Invoke-SwisVerb -SwisConnection $SwisConnection -Entity 'Orion.Container' -Verb 'CreateContainer' -Arguments @( $GroupName, "Core", 60, 0, $GroupDescription, "true", $MemberDefinitions.DocumentElement )# Output the group ID for funWrite-Host "We created a group with ID: $( $BuildGroupResponse.InnerText )"
And this is what it did on my lab system:
Hope that helps!