Applies To:

GroupID 10 – GroupID Management Shell

Business Case:

We have a requirement to change the queries for a large number of Smart Groups. We want the names of the groups and their queries in a CSV file where we can make the required change.


Use GroupID Management Shell to export Smart Group names and queries to a CSV file. Edit the file using MS Excel and change the queries as required. Then import the updated CSV file back into GroupID using GroupID Management Shell. Check the Smart Groups in GroupID and you’ll notice that their queries have changed.


  1. Launch GroupID Management Shell and write the following command:

    -Get-SmartGroup -SearchContainer "DN of the search container" | Select Name, Criteria |Export-CSV "C:\Groups_with_criteria.csv" -NoTypeInformation
  2. This command extracts the queries of all the Smart Groups and Dynasties in the specified OU and exports them to a CSV file named Groups_with_criteria, saved in root C drive. You can select any group attribute; however, criteria is to be used as it is. You can also change the name and path of the CSV file.

    Here is an example output of this CSV:

  3. Open the CSV file with MS Excel and make your desired changes. When done, save the file to CSV format and use the following command to import it to GroupID:

    $g=Import-Csv "Path of the file” (Example: “C:\Groups_1.csv")
  4. Once the file is imported, use the following command to update the queries:

    $g | ForEach-Object {Set-SmartGroup -Identity $_.Name -LDAPFilter $_.Criteria}

    This command works for Smart Groups and not for Dynasties, as we cannot set the Dynasties using the set-smartgroup command.
    Use the following command to update the queries for Dynasties only:
    $g | ForEach-Object {Set-Dynasty -Identity $_.Name -LDAPFilter $_.Criteria}

    It is recommended to split your Smart Groups and Dynasties into two separate CSVs and use the corresponding set commands to set the queries.
Note: Try this method on test groups first. If the results are as per your requirement, apply it to your production critical groups.