Skip to content

Latest commit

 

History

History
168 lines (117 loc) · 4.17 KB

Invoke-KustoQuery.md

File metadata and controls

168 lines (117 loc) · 4.17 KB
external help file Module Name online version schema
PowerShellKusto.dll-Help.xml
PowerShellKusto
2.0.0

Invoke-KustoQuery

SYNOPSIS

Invokes a KQL or T-SQL query over an Azure Data Explorer Cluster.

SYNTAX

Invoke-KustoQuery
    [-Query] <String>
    [[-Database] <String>]
    [-OutputType <OutputType>]
    [-RequestProperties <ClientRequestProperties>]
    [<CommonParameters>]

DESCRIPTION

The Invoke-KustoQuery cmdlet allows you to run Kusto Query Language (KQL) queries or T-SQL queries on a specified Database of your Azure Data Explorer Cluster.

EXAMPLES

Example 1: Run a KQL Query

Invoke-KustoQuery 'search * | summarize count() by $table'

This examples shows how to get the log count summarized by each table.

Tip

In this example, the database is specified by the database used when you called Connect-Kusto.

Example 2: Run a KQL Query on specified Database

Invoke-KustoQuery 'myTable | take 10' -Database myDb

Example 3: Run a KQL Query with specified request properties

$requestProps = New-KustoClientRequestProperties -NoTruncation -ServerTimeout '00:05:00'
Invoke-KustoQuery 'myTable | project fooProp, barProp' -RequestProperties $requestProps

This example demonstrates how you can specify request properties for your query. See also New-KustoClientRequestProperties for more details.

  • In this case -NoTruncation is particularly useful to overcome the 500k row limit on your query.
  • -ServerTimeout '00:05:00' allows the query to run for at least 5 minutes before timing out.

PARAMETERS

-Database

This non mandatory parameter determines which Database in your Cluster will be targetted by your query command.

Note

If not supplied, the Database used will be the one specified when you called Connect-Kusto.

Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-OutputType

Determines the output type this cmdlet will produce. The default value is PSObject.

Type: OutputType
Parameter Sets: (All)
Aliases:
Accepted values: PSObject, Json, Csv, DataTable, Html

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Query

The KQL or T-SQL query you want to run against a specified Database in your Cluster.

Type: String
Parameter Sets: (All)
Aliases:

Required: True
Position: 0
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-RequestProperties

Request properties control how a query or command executes and returns results. If no ClientRequestProperties object is supplied this cmdlet will use default properties.

Note

You can create new request properties using New-KustoClientRequestProperties.

Type: ClientRequestProperties
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

CommonParameters

This cmdlet supports the common parameters. For more information, see about_CommonParameters.

INPUTS

None

OUTPUTS

System.Management.Automation.PSObject

System.String

System.Data.DataTable

The output type from this cmdlet is determined by the -OutputType parameter. By default, this cmdlet outputs PSObject.

NOTES

RELATED LINKS

Kusto Query Language (KQL)

T-SQL

Send T-SQL queries via the REST API