New-SCScriptCommandSetting
建立指令碼命令的設定物件。
Syntax
New-SCScriptCommandSetting
[-AlwaysReboot <Boolean>]
[-FailOnMatch]
[-WarnAndContinueOnMatch]
[-MatchExitCode <String>]
[-MatchStandardError <String>]
[-MatchStandardOutput <String>]
[-PersistStandardErrorPath <String>]
[-PersistStandardOutputPath <String>]
[-MatchRebootExitCode <String>]
[-RestartScriptOnExitCodeReboot <Boolean>]
[-WorkingDirectory <String>]
[-CommandMayReboot]
[-RestartOnRetry <Boolean>]
[<CommonParameters>]
Description
New-SCScriptCommandSetting Cmdlet 會建立指令碼命令的設定物件。
範例
範例 1:將工作目錄設定新增至指令碼命令
PS C:\> $AppProfile = Get-SCApplicationProfile -Name "SvcWebAppProfile01"
PS C:\> $ScriptCommand = Get-SCScriptCommand -ApplicationProfile $AppProfile | where {$_.Name -eq "PostInstall"}
PS C:\> $ScriptSetting = New-SCScriptCommandSetting -WorkingDirectory "Working_Folder_02"
PS C:\> Set-SCScriptCommand -ScriptCommand $ScriptCommand -ScriptCommandSetting $ScriptSetting
第一個命令會取得名為 SvcWebAppProfile01 的應用程式佈建檔物件,並將物件儲存在$AppProfile變數中。
第二個命令會針對儲存在 $AppProfile 中的應用程式佈建檔,取得名為 PostInstall 的指令碼命令物件。
第三個命令會建立新的指令碼命令設定,將工作目錄設定為Working_Folder_02,然後將物件儲存在$ScriptSetting變數中。
最後一個命令會更新儲存在 $ScriptCommand 指令碼命令的工作目錄,以Working_Folder_02 ($ScriptSetting) 的值。
參數
-AlwaysReboot
指出腳本執行完成之後,電腦或虛擬機器應該一律重新開機。
Type: | Boolean |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-CommandMayReboot
表示指令碼命令可能會重新開機電腦或虛擬機器。
Type: | SwitchParameter |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-FailOnMatch
表示在符合失敗原則時所採取的動作是失敗。
Type: | SwitchParameter |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-MatchExitCode
指定失敗原則結束代碼。
範例格式: -MatchExitCode "[1-9][0-9]*"
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-MatchRebootExitCode
指定重新開機原則符合結束代碼。
範例格式: -MatchRebootExitCode "{1641}|{3010}|{3011}"
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-MatchStandardError
指定失敗原則標準錯誤。
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-MatchStandardOutput
指定失敗原則標準輸出。
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-PersistStandardErrorPath
指定要儲存標準錯誤的檔案路徑。
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-PersistStandardOutputPath
指定要儲存標準輸出的檔案路徑。
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-RestartOnRetry
指出當與 New-SCScriptCommandSetting 或 Set-SCScriptCommandSetting搭配使用時,如果先前的工作失敗是因為腳本失敗而重新開機 VMM 作業時,腳本是否重新開機。
Type: | Boolean |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-RestartScriptOnExitCodeReboot
指出當符合結束代碼時,腳本會在電腦或虛擬機器重新開機之後重新開機。
Type: | Boolean |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-WarnAndContinueOnMatch
表示比對失敗原則時所採取的動作是警告使用者並繼續作業。
Type: | SwitchParameter |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-WorkingDirectory
指定指令碼命令的工作目錄。
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
輸出
ScriptCommandSetting
此 Cmdlet 會傳回 ScriptCommandSetting 物件。