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

Add Group Dynamic Queries Using API

Jump to solution

We will be writing some scripts to create Groups through the API and would like to base the members of those Groups on Dynamic Query results like you can do through the web interface.

I did take a look at Groups.ps1 but it does not provide any examples for using a Dynamic Query.

I see in the database where individual members of a Group are stored in Orion.ContainerMemberSnapshots even when I Dynamic Query is used.  I did not find where the actual Dynamic Query is stored in the database.

Can anyone help me with the following:

  1. Where is DQ stored in the Orion database?
  2. What API command(s) can be used to add a DQ to a Group?

 

TIA

Labels (4)
0 Kudos
1 Solution

You can look at a public example I made of a script that builds lots of dynamic groups
https://github.com/Mesverrum/MyPublicWork/blob/master/AppAndAppRoleGroupBuilder.ps1

- Marc Netterfield, Github

View solution in original post

6 Replies

DQ's are defined in the containermembers containermemberdefinition* table.

The best way to understand how to build a DQ for inserting directly in is to build an example of what you need and then tweaking in variables.  I'll warn you that the GUI gets weird if you insert a DQ definition that is not EXACTLY structured the way it wants.  Capitalization and white space has to be exactly right.

- Marc Netterfield, Github
0 Kudos

@mesverrum I guess I do have another question.

You stated that the DQs are stored in the containermembers table.  In that table I do see individual entries for the results of the DQs but not the DQ statements themselves, or I am missing something.  Wouldn't be the first and probably not the last time I missed something ;).  Do you know where the actual DQ statements are stored?

0 Kudos

My mistake, was going from memory they are actually in containermemberdefinition

This SWQL query gets you the DQ's themselves

SELECT TOP 1000 DefinitionID, ContainerID, Name, Entity, FromClause, Expression, Definition
FROM Orion.ContainerMemberDefinition
where definition like 'filter%'

- Marc Netterfield, Github
0 Kudos

Perfect.  Thanks

0 Kudos

You can look at a public example I made of a script that builds lots of dynamic groups
https://github.com/Mesverrum/MyPublicWork/blob/master/AppAndAppRoleGroupBuilder.ps1

- Marc Netterfield, Github

View solution in original post

Breezed through your script and it looks like it will do what we need.  Will be a while before we can actually implement but doing some research upfront.

I also learned a few other things I didn't know in the process.  Thanks for the assist and I will keep in mind what you said about the syntax being picky as well.

Just gotta love this community!!!

0 Kudos