Add-SCSQLScriptCommand
将SQL Server脚本添加到SQL Server应用程序部署。
语法
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>]
说明
Add-SCSQLScriptCommand cmdlet 将 Microsoft SQL Server 脚本添加到SQL Server应用程序部署。
示例
示例 1:将SQL Server脚本添加到应用程序部署
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
第一个命令获取名为 SvcWebAppProfile01 的应用程序配置文件对象,然后将该对象存储在$AppProfile变量中。
第二个命令获取名为 SQLDataTierApp01 的应用程序部署对象作为 SvcWebAppProfile01 应用程序配置文件,然后将该对象存储在$AppDeployment变量中。
第三个命令从 Virtual Machine Manager (VMM) 库获取名为 ConfigureDB.sql 的SQL Server脚本对象,然后将该对象存储在$Script变量中。
最后一个命令将存储在$Script中的SQL Server脚本添加到存储在$AppDeployment中的应用程序部署,并设置脚本将对其运行脚本的脚本类型、部署顺序和数据库。
参数
-ApplicationDeployment
指定应用程序部署对象。
Type: | ApplicationDeployment |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-CommandParameters
指定脚本或可执行程序的参数。
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-DatabaseName
指定SQL Server脚本的数据库的名称。
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-DeploymentOrder
指定计算机层、应用程序主机或应用程序部署的顺序。
Type: | Int32 |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-EncryptConnection
指示是否已加密SQL Server连接。
Type: | Boolean |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-ExecutionTimeoutSeconds
指定SQL Server脚本命令在超时之前等待的时间量(以秒为单位)。
Type: | Int32 |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-JobVariable
指定跟踪和存储作业进度的变量。
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-LoginTimeoutSeconds
指定SQL Server登录在超时之前等待的时间量(以秒为单位)。
Type: | Int32 |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-OutputFilePath
指定用于存储来自SQL Server脚本的输出数据的文件路径。
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-PROTipID
指定触发此操作 (PRO 提示) 的性能和资源优化提示的 ID。 此参数允许审核 PRO 提示。
Type: | Guid |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-RunAsAccount
指定包含具有执行此操作权限的凭据的运行方式帐户。
Type: | VMMCredential |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-RunAsynchronously
指示作业以异步方式运行,以便控件立即返回到命令 shell。
Type: | SwitchParameter |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-SQLAuthenticationType
指定SQL Server身份验证类型。 有效值为:SQLServerAuthentication 和 WindowsAuthentication。
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-SQLScript
指定SQL Server脚本。
Type: | Script |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-SQLScriptType
指定SQL Server脚本类型。 此参数的可接受值为:
- 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
指示脚本是否警告用户,并在运行SQL Server脚本时遇到错误时继续。
Type: | Boolean |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
输出
SQLScriptCommand
此 cmdlet 返回 SQLScriptCommand 对象。