Automate Dynamics 365 FinOp Integration Tasks from PowerShell

Ready to get started?

Download for a free trial:

Download Now

Learn more:

Dynamics 365 FinOp ADO.NET Provider

Rapidly create and deploy powerful .NET applications that integrate with Microsoft Dynamics 365 Finance & Operations data including Vendors, Customers, Accounts, Jobs, and more!

Are you looking for a quick and easy way to access Dynamics 365 FinOp data from PowerShell? We show how to use the Cmdlets for Dynamics 365 FinOp and the CData ADO.NET Provider for Dynamics 365 FinOp to connect to Dynamics 365 FinOp data and synchronize, automate, download, and more.

The CData Cmdlets for Dynamics 365 FinOp 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 Dynamics 365 FinOp.

Cmdlets or ADO.NET?

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

After obtaining the needed connection properties, accessing Dynamics 365 FinOp data in PowerShell consists of three basic steps.

Dynamics 365 for Finance and Operations uses the OAuth authentication standard. See the Getting Started section in the help documentation for an authentication guide.


  1. Install the module:

    Install-Module D365FinOpCmdlets
  2. Connect:

    $d365finop = Connect-D365FinOp -OrganizationUrl "$OrganizationUrl"
  3. Search for and retrieve data:

    $name = "MyAccount" $accounts = Select-D365FinOp -Connection $d365finop -Table "Accounts" -Where "Name = `'$Name`'" $accounts

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

    $accounts = Invoke-D365FinOp -Connection $d365finop -Query 'SELECT * FROM Accounts WHERE Name = @Name' -Params @{'@Name'='MyAccount'}


  1. Load the provider's assembly:

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

    $conn= New-Object System.Data.CData.D365FinOp.D365FinOpConnection("OrganizationUrl=;InitiateOAuth=GETANDREFRESH") $conn.Open()
  3. Instantiate the D365FinOpDataAdapter, execute an SQL query, and output the results:

    $sql="SELECT accountid, Name from Accounts" $da= New-Object System.Data.CData.D365FinOp.D365FinOpDataAdapter($sql, $conn) $dt= New-Object System.Data.DataTable $da.Fill($dt) $dt.Rows | foreach { Write-Host $_.accountid $ }

Update Dynamics 365 FinOp Data


Update-D365FinOp -Connection $D365FinOp -Columns @('accountid','Name') -Values @('Myaccountid', 'MyName') -Table Accounts -Id "MyId"


$cmd = New-Object System.Data.CData.D365FinOp.D365FinOpCommand("UPDATE Accounts SET Name='MyAccount' WHERE Id = @myId", $conn) $cmd.Parameters.Add(new System.Data.CData.D365FinOp.D365FinOpParameter("@myId","10456255-0015501366")) $cmd.ExecuteNonQuery()

Insert Dynamics 365 FinOp Data


Add-D365FinOp -Connection $D365FinOp -Table Accounts -Columns @("accountid", "Name") -Values @("Myaccountid", "MyName")


$cmd = New-Object System.Data.CData.D365FinOp.D365FinOpCommand("INSERT INTO Accounts (Name) VALUES (@myName)", $conn) $cmd.Parameters.Add(new System.Data.CData.D365FinOp.D365FinOpParameter("@myName","MyAccount")) $cmd.ExecuteNonQuery()

Delete Dynamics 365 FinOp Data


Remove-D365FinOp -Connection $D365FinOp -Table "Accounts" -Id "MyId"


$cmd = New-Object System.Data.CData.D365FinOp.D365FinOpCommand("DELETE FROM Accounts WHERE Id=@myId", $conn) $cmd.Parameters.Add(new System.Data.CData.D365FinOp.D365FinOpParameter("@myId","001d000000YBRseAAH")) $cmd.ExecuteNonQuery()