New-SCScriptCommandSetting
Creates a settings object for a script command.
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
The New-SCScriptCommandSetting cmdlet creates a settings object for a script command.
Examples
Example 1: Add a working directory setting to a script command
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
The first command gets the application profile object named SvcWebAppProfile01 and stores the object in the $AppProfile variable.
The second command gets the script command object named PostInstall for the application profile stored in $AppProfile.
The third command creates a new script command setting which sets the working directory to Working_Folder_02, and then stores the object in the $ScriptSetting variable.
The last command updates the working directory for the script command stored in $ScriptCommand to be Working_Folder_02 (the value of $ScriptSetting).
Parameters
-AlwaysReboot
Indicates whether a computer or virtual machine should always restart after the script has finished running.
Type: | Boolean |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-CommandMayReboot
Indicates that the script command may reboot the computer or virtual machine.
Type: | SwitchParameter |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-FailOnMatch
Indicates that the action taken when a failure policy is matched is to fail.
Type: | SwitchParameter |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-MatchExitCode
Specifies the failure policy exit code.
Example format: -MatchExitCode "[1-9][0-9]*"
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-MatchRebootExitCode
Specifies the restart policy match exit code.
Example format: -MatchRebootExitCode "{1641}|{3010}|{3011}"
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-MatchStandardError
Specifies the failure policy standard error.
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-MatchStandardOutput
Specifies the failure policy standard output.
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-PersistStandardErrorPath
Specifies the file path to store the standard error.
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-PersistStandardOutputPath
Specifies the file path to store the standard output.
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-RestartOnRetry
Indicates whether a script is restarted upon VMM job restart if the previous job failure was due to a script failure when used in conjunction with New-SCScriptCommandSetting or Set-SCScriptCommandSetting.
Type: | Boolean |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-RestartScriptOnExitCodeReboot
Indicates whether the script restarts after the computer or virtual machine is restarted when an exit code is matched.
Type: | Boolean |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-WarnAndContinueOnMatch
Indicates that the action taken when a failure policy is matched is to warn the user and continue the operation.
Type: | SwitchParameter |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-WorkingDirectory
Specifies a working directory for a script command.
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Outputs
ScriptCommandSetting
This cmdlet returns a ScriptCommandSetting object.