Ready to get started?

Download a free trial of the Microsoft Teams Data Provider to get started:

 Download Now

Learn more:

Microsoft Teams Icon Microsoft Teams ADO.NET Provider

Rapidly create and deploy powerful .NET applications that integrate with Microsoft Teams.

Automate Microsoft Teams Integration Tasks from PowerShell

Are you in search of a quick and easy way to access Microsoft Teams data from PowerShell? This article demonstrates how to utilize the Microsoft Teams Cmdlets for tasks like connecting to Microsoft Teams data, automating operations, downloading data, and more.

The CData Cmdlets for Microsoft Teams are standard PowerShell cmdlets that make it easy to accomplish data cleansing, normalization, backup, and other integration tasks by enabling real-time and bidirectional access to Microsoft Teams.

PowerShell Cmdlets or ADO.NET Provider?

The Cmdlets are not only a PowerShell interface to Microsoft Teams, but also an SQL interface; this tutorial shows how to use both to create, retrieve, update, and delete Microsoft Teams data. We also show examples of the ADO.NET equivalent, which is possible with the CData ADO.NET Provider for Microsoft Teams. To access Microsoft Teams data from other .NET applications, like LINQPad, use the CData ADO.NET Provider for Microsoft Teams.

Once you have acquired the necessary connection properties, accessing Microsoft Teams data in PowerShell can be enabled in three steps.

You can connect to MS Teams using the embedded OAuth connectivity. When you connect, the MS Teams OAuth endpoint opens in your browser. Log in and grant permissions to complete the OAuth process. See the OAuth section in the online Help documentation for more information on other OAuth authentication flows.


  1. Install the module:

    Install-Module MSTeamsCmdlets
  2. Connect:

    $msteams = Connect-MSTeams -OAuthClientId "$OAuthClientId" -OAuthClientSecret "$OAuthClientSecret" -CallbackURL "$CallbackURL"
  3. Search for and retrieve data:

    $id = "Jq74mCczmFXk1tC10GB" $teams = Select-MSTeams -Connection $msteams -Table "Teams" -Where "Id = `'$Id`'" $teams

    You can also use the Invoke-MSTeams cmdlet to execute SQL commands:

    $teams = Invoke-MSTeams -Connection $msteams -Query 'SELECT * FROM Teams WHERE Id = @Id' -Params @{'@Id'='Jq74mCczmFXk1tC10GB'}


  1. Load the provider's assembly:

    [Reflection.Assembly]::LoadFile("C:\Program Files\CData\CData ADO.NET Provider for Microsoft Teams\lib\System.Data.CData.MSTeams.dll")
  2. Connect to Microsoft Teams:

    $conn= New-Object System.Data.CData.MSTeams.MSTeamsConnection("OAuthClientId=MyApplicationId;OAuthClientSecret=MySecretKey;CallbackURL=http://localhost:33333;InitiateOAuth=GETANDREFRESH") $conn.Open()
  3. Instantiate the MSTeamsDataAdapter, execute an SQL query, and output the results:

    $sql="SELECT subject, location_displayName from Teams" $da= New-Object System.Data.CData.MSTeams.MSTeamsDataAdapter($sql, $conn) $dt= New-Object System.Data.DataTable $da.Fill($dt) $dt.Rows | foreach { Write-Host $_.subject $_.location_displayname }

Update Microsoft Teams Data


Update-MSTeams -Connection $MSTeams -Columns @('subject','location_displayName') -Values @('Mysubject', 'Mylocation_displayName') -Table Teams -Id "MyId"


$cmd = New-Object System.Data.CData.MSTeams.MSTeamsCommand("UPDATE Teams SET Id='Jq74mCczmFXk1tC10GB' WHERE Id = @myId", $conn) $cmd.Parameters.Add((New-Object System.Data.CData.MSTeams.MSTeamsParameter("@myId","10456255-0015501366"))) $cmd.ExecuteNonQuery()

Insert Microsoft Teams Data


Add-MSTeams -Connection $MSTeams -Table Teams -Columns @("subject", "location_displayName") -Values @("Mysubject", "Mylocation_displayName")


$cmd = New-Object System.Data.CData.MSTeams.MSTeamsCommand("INSERT INTO Teams (Id) VALUES (@myId)", $conn) $cmd.Parameters.Add((New-Object System.Data.CData.MSTeams.MSTeamsParameter("@myId","Jq74mCczmFXk1tC10GB"))) $cmd.ExecuteNonQuery()

Delete Microsoft Teams Data


Remove-MSTeams -Connection $MSTeams -Table "Teams" -Id "MyId"


$cmd = New-Object System.Data.CData.MSTeams.MSTeamsCommand("DELETE FROM Teams WHERE Id=@myId", $conn) $cmd.Parameters.Add((New-Object System.Data.CData.MSTeams.MSTeamsParameter("@myId","001d000000YBRseAAH"))) $cmd.ExecuteNonQuery()