Model Context Protocol (MCP) finally gives AI models a way to access the business data needed to make them really useful at work. CData MCP Servers have the depth and performance to make sure AI has access to all of the answers.
Try them now for free →How to pipe Zoho Inventory Data to CSV in PowerShell
Use standard PowerShell cmdlets to access Zoho Inventory tables.
The CData Cmdlets Module for Zoho Inventory is a standard PowerShell module offering straightforward integration with Zoho Inventory. Below, you will find examples of using our ZohoInventory Cmdlets with native PowerShell cmdlets.
Creating a Connection to Your Zoho Inventory Data
In order to connect to Zoho Inventory, set the following connection properties:
- OrganizationId: set this to the ID associated with your specific Zoho Inventory organization
- InitiateOAuth: set the to "GETANDREFRESH"
- AccountsServer (Optional): set this full Account Server URL (only when manually refreshing the OAuth token)
The connectors use OAuth to authenticate with Zoho Inventory. For more information, refer to the Getting Started section of the Help documentation.
$conn = Connect-ZohoInventory -OrganizationId "$OrganizationId" -AccountsServer "$AccountsServer"
Selecting Data
Follow the steps below to retrieve data from the Contacts table and pipe the result into to a CSV file:
Select-ZohoInventory -Connection $conn -Table Contacts | Select -Property * -ExcludeProperty Connection,Table,Columns | Export-Csv -Path c:\myContactsData.csv -NoTypeInformation
You will notice that we piped the results from Select-ZohoInventory 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-ZohoInventory -Connection $conn -Table Contacts -Where "FirstName = Katherine" | Remove-ZohoInventory
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 Zoho Inventory, checking first whether a record already exists and needs to be updated instead of inserted.
Import-Csv -Path C:\MyContactsUpdates.csv | %{ $record = Select-ZohoInventory -Connection $ZohoInventory -Table Contacts -Where ("Id = `'"+$_.Id+"`'") if($record){ Update-ZohoInventory -Connection $zohoinventory -Table Contacts -Columns ("Id","CustomerName") -Values ($_.Id, $_.CustomerName) -Where ("Id = `'"+$_.Id+"`'") }else{ Add-ZohoInventory -Connection $zohoinventory -Table Contacts -Columns ("Id","CustomerName") -Values ($_.Id, $_.CustomerName) } }
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!