Views:

Applies to Product - Microsoft Dataverse


What’s happening?
Customers are seeking a way to automate the creation of Teams within Dynamics 365 using PowerShell scripts.
 

Reason:
The specific PowerShell cmdlet for creating Teams in Dynamics 365 is not available, leading to confusion regarding the correct commands to use.
 

Resolution:
To create a new team in Dynamics CRM using PowerShell, follow these steps:

  1. Install the PowerShell Module:
  2. Open PowerShell as an administrator and run: Install-Module -Name Microsoft.Xrm.Tooling.CrmConnector.PowerShell
  3. Connect to Dynamics CRM:
  4. Use the following command to connect to your Dynamics CRM instance: powershell $Cred = Get-Credential $CRMConn = Get-CrmConnection -Credential $Cred -DeploymentRegion NorthAmerica -Online
  5. Create a New Team:
  6. Use the New-CrmTeam cmdlet to create a new team: powershell New-CrmTeam -Connection $CRMConn -Name "New Team Name" -BusinessUnitId "Business Unit ID"
  7. Replace "New Team Name" with the desired name for your team and "Business Unit ID" with the ID of the business unit to which the team belongs.
  8. Assign Security Roles:
  9. If you need to assign security roles to the team after creation, you can use the following command: powershell # Example command to assign a security role to a team Assign-SecurityRoleToTeam -Connection $CRMConn -TeamId "Team ID" -SecurityRoleId "Security Role ID"
  10. API Alternative:
  11. If the above method does not work, you can create the new team via an API call and then use the team’s name to assign any role.
For further reference, consult the following documentation: - Team table/entity reference (Microsoft Dataverse) - Use PowerShell cmdlets for XRM tooling to connect to Microsoft - Security roles and privileges