Ready to get started?

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

 Download Now

Learn more:

Microsoft Exchange Icon Exchange ADO.NET Provider

The easiest way to integrate powerful Microsoft Exchange send and receive capabilities with .NET applications. Send & Receive Email, manage Exchange messages, folders, calendars, and more!

Automate Microsoft Exchange Integration Tasks from PowerShell

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

The CData Cmdlets for Microsoft Exchange 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 Exchange.

PowerShell Cmdlets or ADO.NET Provider?

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

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

Specify the User and Password to connect to Exchange. Additionally, specify the address of the Exchange server you are connecting to and the Platform associated with the server.


  1. Install the module:

    Install-Module ExchangeCmdlets
  2. Connect:

    $exchange = Connect-Exchange -User "$User" -Password "$Password" -Server "$Server" -Platform "$Platform"
  3. Search for and retrieve data:

    $businnessaddress_city = "Raleigh" $contacts = Select-Exchange -Connection $exchange -Table "Contacts" -Where "BusinnessAddress_City = `'$BusinnessAddress_City`'" $contacts

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

    $contacts = Invoke-Exchange -Connection $exchange -Query 'SELECT * FROM Contacts WHERE BusinnessAddress_City = @BusinnessAddress_City' -Params @{'@BusinnessAddress_City'='Raleigh'}


  1. Load the provider's assembly:

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

    $conn= New-Object System.Data.CData.Exchange.ExchangeConnection("User='';Password='myPassword';Server='';Platform='Exchange_Online';") $conn.Open()
  3. Instantiate the ExchangeDataAdapter, execute an SQL query, and output the results:

    $sql="SELECT GivenName, Size from Contacts" $da= New-Object System.Data.CData.Exchange.ExchangeDataAdapter($sql, $conn) $dt= New-Object System.Data.DataTable $da.Fill($dt) $dt.Rows | foreach { Write-Host $_.givenname $_.size }

Update Microsoft Exchange Data


Update-Exchange -Connection $Exchange -Columns @('GivenName','Size') -Values @('MyGivenName', 'MySize') -Table Contacts -Id "MyId"


$cmd = New-Object System.Data.CData.Exchange.ExchangeCommand("UPDATE Contacts SET BusinnessAddress_City='Raleigh' WHERE Id = @myId", $conn) $cmd.Parameters.Add((New-Object System.Data.CData.Exchange.ExchangeParameter("@myId","10456255-0015501366"))) $cmd.ExecuteNonQuery()

Insert Microsoft Exchange Data


Add-Exchange -Connection $Exchange -Table Contacts -Columns @("GivenName", "Size") -Values @("MyGivenName", "MySize")


$cmd = New-Object System.Data.CData.Exchange.ExchangeCommand("INSERT INTO Contacts (BusinnessAddress_City) VALUES (@myBusinnessAddress_City)", $conn) $cmd.Parameters.Add((New-Object System.Data.CData.Exchange.ExchangeParameter("@myBusinnessAddress_City","Raleigh"))) $cmd.ExecuteNonQuery()

Delete Microsoft Exchange Data


Remove-Exchange -Connection $Exchange -Table "Contacts" -Id "MyId"


$cmd = New-Object System.Data.CData.Exchange.ExchangeCommand("DELETE FROM Contacts WHERE Id=@myId", $conn) $cmd.Parameters.Add((New-Object System.Data.CData.Exchange.ExchangeParameter("@myId","001d000000YBRseAAH"))) $cmd.ExecuteNonQuery()