New-SCScriptCommandSetting
为脚本命令创建设置对象。
语法
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>]
说明
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 对象。