Note
Access to this page requires authorization. You can try signing in or .
Access to this page requires authorization. You can try .
Invoke-ASCmd
- Module:
- SqlServer Module
Enables database administrators to execute an XMLA script, TMSL script, Data Analysis Expressions (DAX) query, Multidimensional Expressions (MDX) query, or Data Mining Extensions (DMX) statement against an instance of Analysis Services.
Syntax
QuerySet (Default)
Invoke-ASCmd
[-WhatIf]
[-Confirm]
[<CommonParameters>]
ParameterSetName
Invoke-ASCmd
[-Database <String>]
[-Query <String>]
[-ConnectionString <String>]
[-QueryTimeout <Int32>]
[-ConnectionTimeout <Int32>]
[-TraceFile <String>]
[-Variables <String[]>]
[-TraceTimeout <Int32>]
[-TraceLevel <TraceLevelOption>]
[-TraceFileFormat <TraceFileFormatOption>]
[-TraceFileDelimiter <String>]
[-Server <String>]
[-Credential <PSCredential>]
[-ServicePrincipal]
[-ApplicationId <String>]
[-TenantId <String>]
[-CertificateThumbprint <String>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
ParameterSetInputObject
Invoke-ASCmd
[-Database <String>]
[-ConnectionString <String>]
[-InputFile <String>]
[-QueryTimeout <Int32>]
[-ConnectionTimeout <Int32>]
[-TraceFile <String>]
[-Variables <String[]>]
[-TraceTimeout <Int32>]
[-TraceLevel <TraceLevelOption>]
[-TraceFileFormat <TraceFileFormatOption>]
[-TraceFileDelimiter <String>]
[-Server <String>]
[-Credential <PSCredential>]
[-ServicePrincipal]
[-ApplicationId <String>]
[-TenantId <String>]
[-CertificateThumbprint <String>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
ParameterSetTabularName
Invoke-ASCmd
[-Server <String>]
[-Credential <PSCredential>]
[-ServicePrincipal]
[-ApplicationId <String>]
[-TenantId <String>]
[-CertificateThumbprint <String>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
ParameterSetTabularInputObject
Invoke-ASCmd
[-Server <String>]
[-Credential <PSCredential>]
[-ServicePrincipal]
[-ApplicationId <String>]
[-TenantId <String>]
[-CertificateThumbprint <String>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Description
Enables database administrators to execute an XMLA script, TMSL script, Data Analysis Expressions (DAX) query, Multidimensional Expressions (MDX) query, or Data Mining Extensions (DMX) statement against an instance of Analysis Services.
The cmdlets execution of these queries or scripts within input files.
The script that is passed is an XMLA command and following commands are supported: Alter, Backup, Batch, BeginTransaction, Cancel, ClearCache, CommitTransaction, Create, Delete, DesignAggregations, Drop, Insert, Lock, MergePartitions, NotifyTableChange, Process, Restore, RollbackTransaction, Statement (used to execute MDX queries and DMX statements), Subscribe, Synchronize, Unlock, Update, UpdateCells.
This script will also accept JSON commands designed to execute against a tabular database with compatibility mode 1200 or higher.
Module requirements: version 21+ on PowerShell 5.1; version 21 (recent preview) or version 22+ on PowerShell 7.x.
Examples
Invoke discover
Invoke-ASCmd -Server:localhost -Query "<Discover xmlns='urn:schemas-microsoft-com:xml-analysis'><RequestType>DBSCHEMA_CATALOGS</RequestType><Restrictions /><Properties /></Discover>"
Invoke discover 2
Invoke-ASCmd -Database "Adventure Works DW 2008R2" -Query "<Discover xmlns='urn:schemas-microsoft-com:xml-analysis'><RequestType>DISCOVER_DATASOURCES</RequestType><Restrictions></Restrictions><Properties></Properties></Discover>"
Invoke select
Invoke-ASCmd -Database "Adventure Works DW 2008R2" -Query "SELECT {[Measures].[Internet Sales Amount]} ON COLUMNS, BOTTOMCOUNT(NONEMPTY(DESCENDANTS( [Customer].[Customer Geography].[All Customers], [Customer].[Customer Geography].[Customer]), ( [Measures].[Internet Sales Amount] ) ), 10, ( [Measures].[Internet Sales Amount] )) ON ROWS FROM [Adventure Works] WHERE ( [Date].[Calendar].[Calendar Year].&[2008] )"
Invoke select 2
Invoke-ASCmd -Database "Adventure Works DW 2008R2" -Query "SELECT MODEL_CATALOG, MODEL_NAME, ATTRIBUTE_NAME, NODE_NAME FROM [Forecasting].CONTENT"
Invoke with xmla file
Invoke-ASCmd -InputFile C:\MyFolder\DiscoverConnections.xmla
<# DiscoverConnections.xmla is as follows:
<Discover xmlns="urn:schemas-microsoft-com:xml-analysis">
<RequestType>DISCOVER_CONNECTIONS</RequestType>
<Restrictions />
<Properties>
<PropertyList>
<Content>Data</Content>
</PropertyList>
</Properties>
</Discover>
#>
Parameters
-ApplicationId
The application Id for the service principal.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-CertificateThumbprint
The certificate thumbprint for the service principal.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-Confirm
Prompts you for confirmation before running the cmdlet.
Parameter properties
| Type: | SwitchParameter |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
| Aliases: | cf |
Parameter sets
-ConnectionString
Specifies the connection string.
Note that other connection-level properties like Server, Database, etc. are ignored when this property is specified and therefore these properties must be included in the connection string.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-ConnectionTimeout
Specifies the number of seconds before the connection to the Analysis Services instance times out. The timeout value must be an integer between 0 and 65534. If 0 is specified, connection attempts do not time out.
Parameter properties
| Type: | Int32 |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-Credential
If this parameter is specified, the user name and password passed will be used to connect to specified Analysis Server instance. If no credentials are specified default windows account of the user who is running the tool will be used.
Parameter properties
| Type: | PSCredential |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-Database
Specifies the database against which an MDX query or DMX statement will execute. The database parameter is ignored when the cmdlet executes an XMLA script, because the database name is embedded in the XMLA script.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-InputFile
Identifies the file that contains the XMLA script, MDX query, DMX statement, or TMSL script (in JSON). You must specify a value for either the InputFile or the *Query *parameter when using Invoke-AsCmd.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-Query
Specifies the actual script, query, or statement directly on the command line instead of in a file.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-QueryTimeout
Specifies the number of seconds before the queries time out. If a timeout value is not specified, the queries do not time out. The timeout must be an integer between 1 and 65535.
Parameter properties
| Type: | Int32 |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-Server
Optionally specifies the server instance to connect to if not currently in the SQLAS Provider directory.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-ServicePrincipal
Specifies that this connection is using service principal.
Parameter properties
| Type: | SwitchParameter |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-TenantId
The tenant Id for the service principal.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-TraceFile
Identifies a file that receives Analysis Services trace events while executing the XMLA script, MDX query, or DMX statement. If the file already exists, it is automatically overwritten (except for the trace files that are created by using the -TraceLevel:Duration and -TraceLevel:DurationResult parameter settings).
File names that contain spaces must be enclosed in quotation marks ("").
If the file name is not valid, an error message is generated.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-TraceFileDelimiter
Specifies a single character as the trace file delimiter when you specify csv as the format for the trace file that use the -TraceFileFormat parameter.
Default is | (pipe, or vertical bar).
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-TraceFileFormat
Specifies the file format for the -TraceFile parameter (if this parameter is specified).
The default value is "Csv".
Parameter properties
| Type: | TraceFileFormatOption |
| Default value: | None |
| Accepted values: | Csv, Text |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-TraceLevel
Specifies what data is collected and recorded in the trace file. Possible values are High, Medium, Low, Duration, DurationResult.
Parameter properties
| Type: | TraceLevelOption |
| Default value: | None |
| Accepted values: | High, Medium, Low, Duration, DurationResult |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-TraceTimeout
Specifies the number of seconds the Analysis Services engine waits before ending the trace (if you specify the -TraceFile parameter).
The trace is considered finished if no trace messages have been recorded during the specified time period.
The default trace time-out value is 5 seconds.
Parameter properties
| Type: | Int32 |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-Variables
Specifies additional scripting variables. Each variable is a name- value pair. If the value contains embedded spaces or control characters, it must be enclosed in double-quotation marks. Use a PowerShell array to specify multiple variables and their values.
Parameter properties
| Type: | String[] |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-WhatIf
Shows what would happen if the cmdlet runs. The cmdlet is not run.
Parameter properties
| Type: | SwitchParameter |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
| Aliases: | wi |
Parameter sets
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
Inputs
PSObject
Outputs
string
Feedback
Was this page helpful?
