Pipe IBM Informix Data to CSV in PowerShell

Ready to get started?

Download for a free trial:

Download Now

Learn more:

IBM Informix Data Cmdlets

An easy-to-use set of PowerShell Cmdlets offering real-time access to IBM Informix. The Cmdlets allow users to easily read, write, update, and delete live data - just like working with SQL server.



Use standard PowerShell cmdlets to access IBM Informix tables.

The CData Cmdlets Module for IBM Informix is a standard PowerShell module offering straightforward integration with IBM Informix. Below, you will find examples of using our Informix Cmdlets with native PowerShell cmdlets.

Creating a Connection to Your IBM Informix Data

Set the following properties to connect to IBM Informix

  • Server: Set this to the name of the server running IBM Informix.
  • Port: Set this to the port the IBM Informix server is listening on.
  • Database: Set this to the name of the IBM Informix database.
  • User: Set this to the username of a user allowed to access the database.
  • Password: Set this to the password of a user allowed to access the database.

You will also need to install the corresponding IBM Informix dependency:

  • Windows: Install the IBM Data Server Provider for .NET.
  • Java: Install the IBM Data Server Driver for JDBC.

$conn = Connect-Informix  -Server "$Server" -Port "$Port" -User "$User" -Password "$Password" -Database "$Database"

Selecting Data

Follow the steps below to retrieve data from the Books table and pipe the result into to a CSV file:

Select-Informix -Connection $conn -Table Books | Select -Property * -ExcludeProperty Connection,Table,Columns | Export-Csv -Path c:\myBooksData.csv -NoTypeInformation

You will notice that we piped the results from Select-Informix into a Select-Object cmdlet and excluded some properties before piping them into an Export-Csv cmdlet. We do this because the CData Cmdlets append Connection, Table, and Columns information onto each "row" in the result set, and we do not necessarily want that information in our CSV file.

The Connection, Table, and Columns are appended to the results in order to facilitate piping results from one of the CData Cmdlets directly into another one.

Deleting Data

The following line deletes any records that match the criteria:

Select-Informix -Connection $conn -Table Books -Where "Category = US" | Remove-Informix

Inserting and Updating Data

The cmdlets make data transformation easy as well as data cleansing. The following example loads data from a CSV file into IBM Informix, checking first whether a record already exists and needs to be updated instead of inserted.

Import-Csv -Path C:\MyBooksUpdates.csv | %{
  $record = Select-Informix -Connection $Informix -Table Books -Where ("Id = `'"+$_.Id+"`'")
  if($record){
    Update-Informix -Connection $informix -Table Books -Columns ("Id","Price") -Values ($_.Id, $_.Price) -Where ("Id = `'"+$_.Id+"`'")
  }else{
    Add-Informix -Connection $informix -Table Books -Columns ("Id","Price") -Values ($_.Id, $_.Price)
  }
}

As always, our goal is to simplify the way you connect to data. With cmdlets users can install a data module, set the connection properties, and start building. Download Cmdlets and start working with your data in PowerShell today!