Add-SCScriptCommand

Adds a script command to an application profile, application deployment, or host profile.

Description

The Add-SCScriptCommand cmdlet adds a script command to an application profile, application deployment, or host profile. A script command allows an Administrator to run code during deployment and servicing operations.

For more information about Add-SCScriptCommand, type: "Get-Help Add-SCScriptCommand -online".

Parameters

ApplicationDeployment

Required? true
Accept Pipeline Input? true (ByValue)
Position? named
Specifies an application deployment object.

Executable

Required? true
Accept Pipeline Input? false
Position? named
Specifies the name of an executable program.

ScriptType

Required? true
Accept Pipeline Input? false
Position? named
Specifies a script type. Valid values are: PreInstall, PostInstall, SaveState, RestoreState, PreService, PostService, PreUninstall, PostUninstall.

CommandParameters

Required? false
Accept Pipeline Input? false
Position? named
Specifies the parameters for a script or executable program.

JobVariable

Required? false
Accept Pipeline Input? false
Position? named
Specifies that job progress is tracked and stored in the variable named by this parameter. 

LibraryResource

Required? false
Accept Pipeline Input? false
Position? named
Specifies a resource stored in the VMM library.

PROTipID

Required? false
Accept Pipeline Input? false
Position? named
Specifies the ID of the PRO tip that triggered this action. This allows for auditing of PRO tips.

RunAsAccount

Required? false
Accept Pipeline Input? false
Position? named
Specifies a Run As account that contains credentials with permission to perform this action.

RunAsynchronously

Required? false
Accept Pipeline Input? false
Position? named
Indicates that the job runs asynchronously so that control returns to the command shell immediately. 

ScriptCommandSetting

Required? false
Accept Pipeline Input? false
Position? named
Specifies a script command setting object.

StandardInput

Required? false
Accept Pipeline Input? false
Position? named
Specifies a path to a file that contains standard input information to use with the script command.

TimeoutSeconds

Required? false
Accept Pipeline Input? false
Position? named
Specifies the amount of time, in seconds, that a process waits before timing out.

VMMServer

Required? false
Accept Pipeline Input? false
Position? named
Specifies a VMM server object.

ApplicationProfile

Required? true
Accept Pipeline Input? true (ByValue)
Position? named
Specifies an application profile object.

Executable

Required? true
Accept Pipeline Input? false
Position? named
Specifies the name of an executable program.

ScriptType

Required? true
Accept Pipeline Input? false
Position? named
Specifies a script type. Valid values are: PreInstall, PostInstall, SaveState, RestoreState, PreService, PostService, PreUninstall, PostUninstall.

CommandParameters

Required? false
Accept Pipeline Input? false
Position? named
Specifies the parameters for a script or executable program.

JobVariable

Required? false
Accept Pipeline Input? false
Position? named
Specifies that job progress is tracked and stored in the variable named by this parameter. 

LibraryResource

Required? false
Accept Pipeline Input? false
Position? named
Specifies a resource stored in the VMM library.

PROTipID

Required? false
Accept Pipeline Input? false
Position? named
Specifies the ID of the PRO tip that triggered this action. This allows for auditing of PRO tips.

RunAsAccount

Required? false
Accept Pipeline Input? false
Position? named
Specifies a Run As account that contains credentials with permission to perform this action.

RunAsynchronously

Required? false
Accept Pipeline Input? false
Position? named
Indicates that the job runs asynchronously so that control returns to the command shell immediately. 

ScriptCommandSetting

Required? false
Accept Pipeline Input? false
Position? named
Specifies a script command setting object.

StandardInput

Required? false
Accept Pipeline Input? false
Position? named
Specifies a path to a file that contains standard input information to use with the script command.

TimeoutSeconds

Required? false
Accept Pipeline Input? false
Position? named
Specifies the amount of time, in seconds, that a process waits before timing out.

VMMServer

Required? false
Accept Pipeline Input? false
Position? named
Specifies a VMM server object.

Executable

Required? true
Accept Pipeline Input? false
Position? named
Specifies the name of an executable program.

VMHostProfile

Required? true
Accept Pipeline Input? true (ByValue)
Position? named
Specifies a virtual machine host profile object.

CommandParameters

Required? false
Accept Pipeline Input? false
Position? named
Specifies the parameters for a script or executable program.

JobVariable

Required? false
Accept Pipeline Input? false
Position? named
Specifies that job progress is tracked and stored in the variable named by this parameter. 

LibraryResource

Required? false
Accept Pipeline Input? false
Position? named
Specifies a resource stored in the VMM library.

PROTipID

Required? false
Accept Pipeline Input? false
Position? named
Specifies the ID of the PRO tip that triggered this action. This allows for auditing of PRO tips.

RunAsynchronously

Required? false
Accept Pipeline Input? false
Position? named
Indicates that the job runs asynchronously so that control returns to the command shell immediately. 

ScriptCommandSetting

Required? false
Accept Pipeline Input? false
Position? named
Specifies a script command setting object.

StandardInput

Required? false
Accept Pipeline Input? false
Position? named
Specifies a path to a file that contains standard input information to use with the script command.

TimeoutSeconds

Required? false
Accept Pipeline Input? false
Position? named
Specifies the amount of time, in seconds, that a process waits before timing out.

VMMServer

Required? false
Accept Pipeline Input? false
Position? named
Specifies a VMM server object.

Examples

1: Add a script command to an application profile.
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
The first command gets the application profile object named SvcWebAppProfile01 and stores the object in the $AppProfile variable.

The second command creates a script command setting object that sets the working directory to Payload, and then stores the object in the $ScriptSetting variable.

The last command adds a preinstall script command to the application profile stored in $AppProfile.

See Also