web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Service | Customer Service, Contact Center, Fie...
Suggested Answer

Export Guides Operator and Guides Author members

(1) ShareShare
ReportReport
Posted on by 7

Need help exporting all of the accounts with the Guides Operator and Guides Author roles.  We have several Guides environments and need to collect this information for all of the environments.  Running a manual advanced query for each environment takes to long due to the number of environments we have.

I have the same question (0)
  • Oren Shir Profile Picture
    on at

    When you wrote accounts, did you mean users?

    Which tool do you want to use to get the information? You can use PowerShell, Power Automate, or write code, and more.

    Where do you want to export to? A file like excel/xml/json/csv, or some other system like a SharePoint table?

    I assume the roles are the default ones that come with the product.

     

    The information is all in CDS, this is an example for how to use the API Sample: Associate a Security Role to a User (Developer Guide for Dynamics 365 Customer Engagement) | Microsoft Docs . You need to decide on your favorite way to interact with the systemuserroles_association collection value navigation property of the role EntityType (Microsoft.Dynamics.CRM) | Microsoft Docs .

    For example, if you want to use PowerShell you can get started at Microsoft Dynamics CRM PowerShell Reference | Microsoft Docs .

    There are many links about using Power Automate to query CDS.

    After you add more details we can help you find the solution you need.

  • Dan Coan Profile Picture
    7 on at

    Yes, user accounts.

    PowerShell usually works easiest.

    Simple CSV file is sufficient.

    Yes, the default roles are the ones I looking for.

  • Suggested answer
    Oren Shir Profile Picture
    on at

    If you look at the PowerShell in the Guide content migration tool (Migrate Dynamics 365 Guides content from one Microsoft Dataverse instance to another using the Content Migration Tool (Public Preview) - Dynamics 365 Mixed Reality | Microsoft Docs) you can find code snippets that can help you construct the script you need.

    Because you want to connect to many instances, I suggest you follow the instructions in Use PowerShell cmdlets for XRM tooling to connect to Microsoft Dataverse (Dataverse) - Power Apps | Microsoft Docs
    $Cred = Get-Credential
    $CRMConn = Get-CrmConnection -Credential $Cred -DeploymentRegion <Deployment region name> –OnlineType Office365 –OrganizationName <OrgName>
     
    You can also use connection string, just be careful about the where you put the password so it doesn't leak. You can also create an application user and associate it with a certificate if you don't want to sign in or have the password stored on a machine. Try to avoid using the options that just put the password in the connection string. Simplest way to start is
    $CRMConn = Get-CrmConnection -InteractiveMode
    The rest uses standard SDK queries. It is a little more complicated because roles to users is a N:N relationship
    $condition = new-object Microsoft.Xrm.Sdk.Query.ConditionExpression
    $condition.AttributeName = "name"
    $condition.Operator = "Equal"
    $condition.Values.Add("Dynamics 365 Guides Restricted Author")
    $filter = new-object Microsoft.Xrm.Sdk.Query.FilterExpression
    $filter.Conditions.Add($condition)
    $roleLink = new-object Microsoft.Xrm.Sdk.Query.LinkEntity
    $roleLink.LinkFromEntityName = "systemuserroles"
    $roleLink.LinkFromAttributeName = "roleid"
    $roleLink.LinkToEntityName = "role"
    $roleLink.LinkToAttributeName = "roleid"
    $roleLink.LinkCriteria.AddFilter($filter)

    $systemUserLink = new-object Microsoft.Xrm.Sdk.Query.LinkEntity
    $systemUserLink.LinkFromEntityName = "systemuser"
    $systemUserLink.LinkFromAttributeName = "systemuserid"
    $systemUserLink.LinkToEntityName = "systemuserroles"
    $systemUserLink.LinkToAttributeName = "systemuserid"

    $systemUserLink.LinkEntities.Add($roleLink)

    $linkQuery = new-object Microsoft.Xrm.Sdk.Query.QueryExpression $true
    $linkQuery.EntityName = "systemuser"
    $linkQuery.ColumnSet = new-object Microsoft.Xrm.Sdk.Query.ColumnSet($true)
    $linkQuery.LinkEntities.Add($systemUserLink);

    $request = new-object Microsoft.Xrm.Sdk.Messages.RetrieveMultipleRequest
    $request.Query = $linkQuery
    $res = $CRMConn.Execute($request)

    The users are in $res.EntityCollection.Entities . You should loop over this collection and save it in the format you want. This link has examples Export-Csv (Microsoft.PowerShell.Utility) - PowerShell | Microsoft Docs

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Service | Customer Service, Contact Center, Field Service, Guides

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 55 Super User 2025 Season 2

#2
Daniyal Khaleel Profile Picture

Daniyal Khaleel 27 Most Valuable Professional

#3
Soundari Profile Picture

Soundari 15

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans