Add-SCScriptCommand
將指令碼命令新增至應用程式佈建檔、應用程式部署或主機設定檔。
Syntax
Add-SCScriptCommand
-ApplicationProfile <ApplicationProfile>
[-Executable <String>]
[-CommandParameters <String>]
[-ScriptCommandSetting <SCScriptCommandSetting>]
-ScriptType <ScriptCommandType>
[-TimeoutSeconds <Int32>]
[-StandardInput <String>]
[-LibraryResource <CustomResource>]
[-RunAsAccount <VMMCredential>]
[-VMMServer <ServerConnection>]
[-DeploymentOrder <Int32>]
[-RunAsynchronously]
[-PROTipID <Guid>]
[-JobVariable <String>]
[<CommonParameters>]
Add-SCScriptCommand
-ApplicationDeployment <ApplicationDeployment>
[-Executable <String>]
[-CommandParameters <String>]
[-ScriptCommandSetting <SCScriptCommandSetting>]
-ScriptType <ScriptCommandType>
[-TimeoutSeconds <Int32>]
[-StandardInput <String>]
[-LibraryResource <CustomResource>]
[-RunAsAccount <VMMCredential>]
[-VMMServer <ServerConnection>]
[-DeploymentOrder <Int32>]
[-RunAsynchronously]
[-PROTipID <Guid>]
[-JobVariable <String>]
[<CommonParameters>]
Add-SCScriptCommand
-PhysicalComputerProfile <PhysicalComputerProfile>
[-Executable <String>]
[-CommandParameters <String>]
[-ScriptCommandSetting <SCScriptCommandSetting>]
-ScriptType <ScriptCommandType>
[-TimeoutSeconds <Int32>]
[-StandardInput <String>]
[-LibraryResource <CustomResource>]
[-RunAsAccount <VMMCredential>]
[-VMMServer <ServerConnection>]
[-JobGroup <Guid>]
[-DeploymentOrder <Int32>]
[-RunAsynchronously]
[-PROTipID <Guid>]
[-JobVariable <String>]
[<CommonParameters>]
Add-SCScriptCommand
[-Executable <String>]
[-CommandParameters <String>]
[-ScriptCommandSetting <SCScriptCommandSetting>]
-ScriptType <ScriptCommandType>
[-TimeoutSeconds <Int32>]
[-StandardInput <String>]
[-LibraryResource <CustomResource>]
[-RunAsAccount <VMMCredential>]
[-VMMServer <ServerConnection>]
[-JobGroup <Guid>]
[-DeploymentOrder <Int32>]
[-RunAsynchronously]
[-PROTipID <Guid>]
[-JobVariable <String>]
[<CommonParameters>]
Description
Add-SCScriptCommand Cmdlet 會將指令碼命令新增至應用程式佈建檔、應用程式部署或主機設定檔。 指令碼命令可讓系統管理員在部署和維護作業期間執行程式碼。
範例
範例 1:將指令碼命令新增至應用程式佈建檔
PS C:\> $AppProfile = Get-SCApplicationProfile -Name "SvcWebAppProfile01"
PS C:\> $ScriptSetting = New-SCScriptCommandSetting -WorkingDirectory "Working_Folder_01"
PS C:\> Add-SCScriptCommand -ApplicationProfile $AppProfile -Executable "Startup.ps1" -ScriptType "PreInstall" -ScriptCommandSetting $ScriptSetting -TimeoutSeconds 120
第一個命令會取得名為 SvcWebAppProfile01 的應用程式佈建檔物件,並將物件儲存在$AppProfile變數中。
第二個命令會建立指令碼命令設定物件,將工作目錄設定為 Payload,然後將物件儲存在$ScriptSetting變數中。
最後一個命令會將預先安裝指令碼命令新增至儲存在 $AppProfile 的應用程式佈建檔。
參數
-ApplicationDeployment
指定應用程式部署物件。
Type: | ApplicationDeployment |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-ApplicationProfile
指定應用程式佈建檔物件。
Type: | ApplicationProfile |
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 |
-DeploymentOrder
指定部署電腦層、應用程式主機或應用程式的順序。
Type: | Int32 |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-Executable
指定可執行程式的名稱。
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-JobGroup
指定一系列命令的識別碼,這些命令會在執行包含相同工作群組識別碼的最終命令之前,使用整組的方式來執行。
Type: | Guid |
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 |
-LibraryResource
指定儲存在 Virtual Machine Manager (VMM) 程式庫中的資源。
Type: | CustomResource |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-PhysicalComputerProfile
指定用來將作業系統部署至電腦的設定檔。
Type: | PhysicalComputerProfile |
Aliases: | VMHostProfile |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-PROTipID
指定觸發此動作 (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 |
-ScriptCommandSetting
指定指令碼命令設定物件。
Type: | SCScriptCommandSetting |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-ScriptType
指定腳本類型。 此參數可接受的值為:
- 預先安裝
- PostInstall
- SaveState
- RestoreState
- PreService
- PostService
- PreUninstall
- PostUninstall
- OrderedCommand
- BareMetalPostWinPERegistration
- OnProvisionFirst
- OnProvisionRest
- OnDeleteLast
- OnDeleteRest
- 安裝
- BareMetalPostDeployment
Type: | ScriptCommandType |
Accepted values: | PreService, PostService, SaveState, RestoreState, PreInstall, PostInstall, PreUninstall, PostUninstall, OrderedCommand, BareMetalPostWinPERegistration, OnProvisionFirst, OnProvisionRest, OnDeleteLast, OnDeleteRest, Install, BareMetalPostConfiguration, BareMetalPostUnattend |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-StandardInput
指定檔案的路徑,其中包含要與指令碼命令搭配使用的標準輸入資訊。
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-TimeoutSeconds
指定進程在逾時前等候的時間量,以秒為單位。
Type: | Int32 |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-VMMServer
指定 Virtual Machine Manager (VMM) 伺服器物件。
Type: | ServerConnection |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
輸出
ScriptCommand
此 Cmdlet 會傳回 ScriptCommand 物件。