Add-SCSQLScriptCommand

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

Syntax

Add-SCSQLScriptCommand
   [-LoginTimeoutSeconds <Int32>]
   [-ExecutionTimeoutSeconds <Int32>]
   [-RunAsAccount <VMMCredential>]
   -ApplicationDeployment <ApplicationDeployment>
   -SQLScriptType <SQLScriptCommandType>
   -SQLScript <Script>
   -DeploymentOrder <Int32>
   [-CommandParameters <String>]
   [-OutputFilePath <String>]
   [-EncryptConnection <Boolean>]
   [-DatabaseName <String>]
   [-SQLAuthenticationType <String>]
   [-WarnAndContinueOnError <Boolean>]
   [-RunAsynchronously]
   [-PROTipID <Guid>]
   [-JobVariable <String>]
   [<CommonParameters>]

Description

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

Examples

Example 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 then stores that object in the $AppProfile variable.

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

The third command gets the SQL Server script object named ConfigureDB.sql, release 1.0, from the Virtual Machine Manager (VMM) library, and then stores that object in the $Script variable.

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.

Parameters

-ApplicationDeployment

Specifies an application deployment object.

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

-CommandParameters

Specifies the parameters for a script or executable program.

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

-DatabaseName

Specifies the name of a database for a SQL Server script.

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

-DeploymentOrder

Specifies the order in which a computer tier, application host, or application is deployed.

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

-EncryptConnection

Indicates whether the SQL Server connection is encrypted.

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

-ExecutionTimeoutSeconds

Specifies the amount of time, in seconds, that the SQL Server script command waits before it times out.

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

-JobVariable

Specifies a variable in which job progress is tracked and stored.

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

-LoginTimeoutSeconds

Specifies the amount of time, in seconds, that a SQL Server login waits before it times out.

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

-OutputFilePath

Specifies a file path to store output data from a SQL Server script.

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

-PROTipID

Specifies the ID of the Performance and Resource Optimization tip (PRO tip) that triggered this action. This parameter lets you audit PRO tips.

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

-RunAsAccount

Specifies a Run As account that contains credentials with permission to perform this action.

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

-RunAsynchronously

Indicates that the job runs asynchronously so that control returns to the command shell immediately.

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

-SQLAuthenticationType

Specifies the SQL Server authentication type. Valid values are: SQLServerAuthentication and WindowsAuthentication.

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

-SQLScript

Specifies a SQL Server script.

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

-SQLScriptType

Specifies a SQL Server script type. The acceptable values for this parameter are:

  • PreInstall
  • PostInstall
  • PreService
  • PostService
  • PreUninstall
  • PostUninstall
Type:SQLScriptCommandType
Accepted values:PreInstall, PostInstall, PreService, PostService, PreUninstall, PostUninstall
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-WarnAndContinueOnError

Indicates whether the script warns the user and continues if the SQL Server script encounters an error while it runs.

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

Outputs

SQLScriptCommand

This cmdlet returns a SQLScriptCommand object.