Add-SCSQLScriptCommand

Adds a SQL Server script to a SQL Server application deployment.

Description

The Add-SQLScriptCommand cmdlet adds a SQL Server script to a SQL Server application deployment.

For more information about Add-SQLScriptCommand, type: "Get-Help Add-SQLScriptCommand -online".

Parameters

ApplicationDeployment

Required? true
Accept Pipeline Input? true (ByValue)
Position? named
Specifies an application deployment object.

DeploymentOrder

Required? true
Accept Pipeline Input? false
Position? named
Specifies the order in which a computer tier or application host is deployed.

SQLScript

Required? true
Accept Pipeline Input? false
Position? named
Specifies a SQL Server script.

SQLScriptType

Required? true
Accept Pipeline Input? false
Position? named
Specifies a SQL Server script type. Valid values are: PreInstall, PostInstall, PreService, PostService, PreUninstall, PostUninstall.

CommandParameters

Required? false
Accept Pipeline Input? false
Position? named
Specifies the parameters for a script or executable program.

DatabaseName

Required? false
Accept Pipeline Input? false
Position? named
Specifies the name of a database for a SQL Server script.

EncryptConnection

Required? false
Accept Pipeline Input? false
Position? named
Specifies whether the SQL Server connection is encrypted.

ExecutionTimeoutSeconds

Required? false
Accept Pipeline Input? false
Position? named
Specifies the amount of time, in seconds, that the SQL Server script command (SQL statement) will wait before timing out.

JobVariable

Required? false
Accept Pipeline Input? false
Position? named
Specifies that job progress is tracked and stored in the variable named by this parameter. 

LoginTimeoutSeconds

Required? false
Accept Pipeline Input? false
Position? named
Specifies the amount of time, in seconds, that a SQL Server login waits before timing out.

OutputFilePath

Required? false
Accept Pipeline Input? false
Position? named
Specifies a file path to store output data from a SQL Server script.

PROTipID

Required? false
Accept Pipeline Input? false
Position? named
Specifies the ID of the PRO tip that triggered this action. This allows for auditing of PRO tips.

RunAsAccount

Required? false
Accept Pipeline Input? false
Position? named
Specifies a Run As account that contains credentials with permission to perform this action.

RunAsynchronously

Required? false
Accept Pipeline Input? false
Position? named
Indicates that the job runs asynchronously so that control returns to the command shell immediately. 

SQLAuthenticationType

Required? false
Accept Pipeline Input? false
Position? named
Specifies the SQL Server authentication type. Valid valus are: SQLServerAuthentication, WindowsAuthentication.

WarnAndContinueOnError

Required? false
Accept Pipeline Input? false
Position? named
Indicates whether the script should warn the user and continue if the SQL Server script encounters an error while running.

Examples

1: Add a SQL Server script to an application deployment.
PS C:\> $AppProfile = Get-SCApplicationProfile -Name "SvcWebAppProfile01"
PS C:\> $AppDeployment = Get-SCApplicationDeployment -ApplicationProfile $AppProfile -Name "SQLDataTierApp01"
PS C:\> $SQLScript = Get-SCScript -Name "ConfigDB.sql" -Release "1.0"
PS C:\> Add-SCSQLScriptCommand -ApplicationDeployment $AppDeployment -SQLScriptType "PreInstall" -DeploymentOrder 1 -DatabaseName "MSSQLSERVER" -SQLScript $SQLScript
The first command gets the application profile object named SvcWebAppProfile01 and stores the object in the $AppProfile variable.

The second command gets the application deployment object named SQLDataTierApp01 for the SvcWebAppProfile01 application profile, and then stores the object in the $AppDeployment variable.

The third command gets the SQL Server script object named ConfigureDB.sql, release 1.0, from the VMM library and stores the object in the $Script varaible.

The last command adds the SQL Server script stored in $Script to the application deployment stored in $AppDeployment and sets the script type, deployment order, and database against which the script will run.

See Also