Add-SCSQLScriptCommand
將SQL Server腳本新增至SQL Server應用程式部署。
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
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變數中。
第二個命令會取得 SvcWebAppProfile01 應用程式佈建檔案名為 SQLDataTierApp01 的應用程式部署物件,然後將該物件儲存在$AppDeployment變數中。
第三個命令會從 Virtual Machine Manager (VMM) 程式庫,取得名為 ConfigureDB.sql 1.0 版的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 提示 (PRO 提示的識別碼) 。 此參數可讓您稽核 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
表示作業會以非同步方式執行,讓控制項立即返回命令殼層。
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腳本類型。 此參數可接受的值為:
- 預先安裝
- 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 物件。