Ready to get started?

Learn more about the UPS PowerShell Cmdlets or download a free trial:

Download Now

Pipe UPS Data to CSV in PowerShell

Use standard PowerShell cmdlets to access UPS tables.

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

Creating a Connection to Your UPS Data

The driver uses five pieces of information in order to authenticate its actions with the UPS service.

  • Server: This controls the URL where the requests should be sent. Common testing options for this are: and
  • AccessKey: This is an identifier that is required to connect to a UPS Server. This value will be provided to you by UPS after registration.
  • UserId: This value is used for logging into UPS. This value is the one you chose to login with when registering for service with UPS.
  • Password: This value is used for logging into UPS. This value is the one you chose to login with when registering for service with UPS.
  • AccountNumber: This is a valid 6-digit or 10-digit UPS account number.
  • PrintLabelLocation: This property is required if one intends to use the GenerateLabels or GenerateReturnLabels stored procedures. This should be set to the folder location where generated labels should be stored.

$conn = Connect-UPS  -Server "$Server" -AccessKey "$AccessKey" -Password "$Password" -AccountNumber "$AccountNumber" -UserId "$UserId"

Selecting Data

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

Select-UPS -Connection $conn -Table Senders | Select -Property * -ExcludeProperty Connection,Table,Columns | Export-Csv -Path c:\mySendersData.csv -NoTypeInformation

You will notice that we piped the results from Select-UPS 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-UPS -Connection $conn -Table Senders -Where "SenderID = 25" | Remove-UPS

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 UPS, checking first whether a record already exists and needs to be updated instead of inserted.

Import-Csv -Path C:\MySendersUpdates.csv | %{
  $record = Select-UPS -Connection $UPS -Table Senders -Where ("Id = `'"+$_.Id+"`'")
    Update-UPS -Connection $ups -Table Senders -Columns ("FirstName","Phone") -Values ($_.FirstName, $_.Phone) -Where ("Id = `'"+$_.Id+"`'")
    Add-UPS -Connection $ups -Table Senders -Columns ("FirstName","Phone") -Values ($_.FirstName, $_.Phone)

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!