Export (0) Print
Expand All
Expand Minimize

Add-SCSQLScriptCommand

Updated: April 29, 2014

Applies To: System Center 2012 R2 Virtual Machine Manager

Add-SCSQLScriptCommand

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

Syntax

Parameter Set: Default
Add-SCSQLScriptCommand -ApplicationDeployment <ApplicationDeployment> -DeploymentOrder <Int32> -SQLScript <Script> -SQLScriptType <SQLScriptCommandType> {PreInstall | PostInstall | PreService | PostService | PreUninstall | PostUninstall} [-CommandParameters <String> ] [-DatabaseName <String> ] [-EncryptConnection <Boolean> ] [-ExecutionTimeoutSeconds <Int32> ] [-JobVariable <String> ] [-LoginTimeoutSeconds <Int32> ] [-OutputFilePath <String> ] [-PROTipID <Guid> ] [-RunAsAccount <VMMCredential> ] [-RunAsynchronously] [-SQLAuthenticationType <String> ] [-WarnAndContinueOnError <Boolean> ] [ <CommonParameters>]




Detailed Description

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

Parameters

-ApplicationDeployment<ApplicationDeployment>

Specifies an application deployment object.


Aliases

none

Required?

true

Position?

named

Default Value

none

Accept Pipeline Input?

True (ByValue)

Accept Wildcard Characters?

false

-CommandParameters<String>

Specifies the parameters for a script or executable program.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-DatabaseName<String>

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


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-DeploymentOrder<Int32>

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


Aliases

none

Required?

true

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-EncryptConnection<Boolean>

Specifies whether the SQL Server connection is encrypted.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-ExecutionTimeoutSeconds<Int32>

Specifies the amount of time, in seconds, that the SQL Server script command (SQL statement) waits before timing out.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-JobVariable<String>

Specifies that job progress is tracked and stored in the variable named by this parameter.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-LoginTimeoutSeconds<Int32>

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


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-OutputFilePath<String>

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


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-PROTipID<Guid>

Specifies the ID of the PRO tip that triggered this action. This allows for auditing of PRO tips.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-RunAsAccount<VMMCredential>

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


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-RunAsynchronously

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


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-SQLAuthenticationType<String>

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


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-SQLScript<Script>

Specifies a SQL Server script.


Aliases

none

Required?

true

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-SQLScriptType<SQLScriptCommandType>

Specifies a SQL Server script type. Valid values are:

-- PreInstall
-- PostInstall
-- PreService
-- PostService
-- PreUninstall
-- PostUninstall


Aliases

none

Required?

true

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-WarnAndContinueOnError<Boolean>

Indicates whether the script should warn the user and continue if the SQL Server script encounters an error while running.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

<CommonParameters>

This cmdlet supports the common parameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutBuffer, and -OutVariable. For more information, see about_CommonParameters.

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

Outputs

The output type is the type of the objects that the cmdlet emits.

  • SQLScriptCommand

Examples

Example 1: Add a SQL Server script to an application deployment

The first command gets the application profile object named SvcWebAppProfile01, and then 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 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 runs.


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

Related topics

 
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft