Ready to get started?

Learn more about the Azure Analysis Services PowerShell Cmdlets or download a free trial:

Download Now

Pipe Azure Analysis Services Data to CSV in PowerShell

Use standard PowerShell cmdlets to access Azure Analysis Services tables.

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

Creating a Connection to Your Azure Analysis Services Data

To connect to Azure Analysis Services, set the Url property to a valid server, for instance, asazure://, in addition to authenticating. Optionally, set Database to distinguish which Azure database on the server to connect to.

Azure Analysis Services uses the OAuth authentication standard. OAuth requires the authenticating user to interact with Azure Analysis Services using the browser. You can connect without setting any connection properties for your user credentials. See the Help documentation for more information.

$conn = Connect-AAS  -URL "$URL"

Selecting Data

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

Select-AAS -Connection $conn -Table Customer | Select -Property * -ExcludeProperty Connection,Table,Columns | Export-Csv -Path c:\myCustomerData.csv -NoTypeInformation

You will notice that we piped the results from Select-AAS 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.