Ready to get started?

Learn more about the CData ADO.NET Provider for Open Exchange Rates or download a free trial:

Download Now

Automate Open Exchange Rates Integration Tasks from PowerShell

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

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

Cmdlets or ADO.NET?

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

After obtaining the needed connection properties, accessing Open Exchange Rates data in PowerShell consists of three basic steps.

The Open Exchange Rates API supports basic authentication with an App Id. After you register, your App Id is displayed in your account dashboard. Set this to the AppId connection property.

PowerShell

  1. Install the module:

    Install-Module OpenExchangeRatesCmdlets
  2. Connect:

    $openexchangerates = Connect-OpenExchangeRates -AppId "$AppId"
  3. Search for and retrieve data:

    $id = "MyProjectId" $projects = Select-OpenExchangeRates -Connection $openexchangerates -Table "Projects" -Where "Id = `'$Id`'" $projects

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

    $projects = Invoke-OpenExchangeRates -Connection $openexchangerates -Query 'SELECT * FROM Projects WHERE Id = @Id' -Params @{'@Id'='MyProjectId'}

ADO.NET

  1. Load the provider's assembly:

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

    $conn= New-Object System.Data.CData.OpenExchangeRates.OpenExchangeRatesConnection("AppId=abc1234;") $conn.Open()
  3. Instantiate the OpenExchangeRatesDataAdapter, execute an SQL query, and output the results:

    $sql="SELECT Id, Statistics_ViewCount from Projects" $da= New-Object System.Data.CData.OpenExchangeRates.OpenExchangeRatesDataAdapter($sql, $conn) $dt= New-Object System.Data.DataTable $da.Fill($dt) $dt.Rows | foreach { Write-Host $_.id $_.statistics_viewcount }