Set-SCScriptCommandSetting
配置脚本命令设置。
语法
Set-SCScriptCommandSetting
[-ScriptCommandSetting] <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>]
说明
Set-SCScriptCommandSetting cmdlet 配置脚本命令设置。
示例
示例 1:更新与脚本命令关联的工作目录
PS C:\> $AppProfile = Get-SCApplicationProfile -Name "SvcWebAppProfile01"
PS C:\> $ScriptCommand = Get-SCScriptCommand -ApplicationProfile $AppProfile | where {$_.Name -eq "PreInstall"}
PS C:\> $ScriptCmdSetting = Get-SCScriptCommandSetting -ScriptCommand $ScriptCommand
PS C:\> Set-SCScriptCommandSetting -ScriptCommandSetting $ScriptCmdSetting -WorkingDirectory "Working_Folder_03"
PS C:\> Set-SCScriptCommand -ScriptCommand $ScriptCommand -ScriptCommandSetting $ScriptCmdSetting
第一个命令获取名为 SvcWebAppProfile01 的应用程序配置文件对象,并将对象存储在$AppProfile变量中。
第二个命令获取名为 PreInstall 的应用程序配置文件的脚本命令,该命令存储在$AppProfile中,然后将对象存储在$ScriptCommand变量中。
第三个命令获取存储在$ScriptCommand中的脚本命令的脚本命令设置对象,并将对象存储在$ScriptCmdSetting变量中。
第四个命令将工作目录设置设置为Working_Folder_03。
最后一个命令使用存储在$ScriptCmdSetting中的设置更新存储在$ScriptCommand中的脚本命令。
参数
-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 |
-ScriptCommandSetting
指定脚本命令设置对象。
Type: | SCScriptCommandSetting |
Position: | 0 |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
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 对象。