Set-SCSQLScriptCommand

Set-SCSQLScriptCommand

Modifies the properties of a SQL Server script.

Syntax

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

Detailed Description

The Set-SCSQLScriptCommand cmdlet modifies the properties of a Microsoft SQL Server script associated with an application deployment.

Parameters

-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?

false

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 Performance and Resource Optimization tip (PRO tip) that triggered this action. This parameter lets you audit 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 and 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?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-SQLScriptCommand<SCSQLScriptCommand>

Specifies a SQL Server script command object.

Aliases

none

Required?

true

Position?

1

Default Value

none

Accept Pipeline Input?

True (ByValue)

Accept Wildcard Characters?

false

-SQLScriptType<SQLScriptCommandType>

Specifies a SQL Server script type. Valid values are:

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

Aliases

none

Required?

false

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 (https://go.microsoft.com/fwlink/p/?LinkID=113216).

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: Modify a SQL Server script command

The first command gets the application profile object named SvcWebAppProfile01, and then stores it in the $AppProfile variable.

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

The third command gets the first PreInstall SQL Server script object associated with the application deployment stored in $AppDeployment, and then stores the object in the $SQLScript variable. To get the first PreInstall SQL Server script, the command specifies a DeploymentOrder of 1 and a SQLScriptType of PreInstall.

The last command modifies the database against which the SQL Server script stored $SQLScript runs.

PS C:\> $AppProfile = Get-SCApplicationProfile -Name "SvcWebAppProfile01"
PS C:\> $AppDeployment = Get-SCApplicationDeployment -ApplicationProfile $AppProfile -Name "SQLDataTierApp01"
PS C:\> $SQLScript = Get-SCSQLScriptCommand -ApplicationDeployment $AppDeployment | where {$_.DeploymentOrder -eq "1" -and $_.SQLScriptType -eq "PreInstall"}
PS C:\> Set-SCSQLScriptCommand -SQLScriptCommand $SQLScript -DatabaseName "MSOrders"

Add-SCSQLScriptCommand

Get-SCSQLScriptCommand

Remove-SCSQLScriptCommand

Get-SCApplicationProfile

Get-SCApplicationDeployment