Add-SCScriptCommand

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

Syntax

Add-SCScriptCommand -ApplicationDeployment <ApplicationDeployment> [-CommandParameters <String>]
 [-DeploymentOrder <Int32>] [-Executable <String>] [-JobVariable <String>] [-LibraryResource <CustomResource>]
 [-PROTipID <Guid>] [-RunAsAccount <VMMCredential>] [-RunAsynchronously]
 [-ScriptCommandSetting <SCScriptCommandSetting>] -ScriptType <ScriptCommandType> [-StandardInput <String>]
 [-TimeoutSeconds <Int32>] [-VMMServer <ServerConnection>] [<CommonParameters>]
Add-SCScriptCommand -ApplicationProfile <ApplicationProfile> [-CommandParameters <String>]
 [-DeploymentOrder <Int32>] [-Executable <String>] [-JobVariable <String>] [-LibraryResource <CustomResource>]
 [-PROTipID <Guid>] [-RunAsAccount <VMMCredential>] [-RunAsynchronously]
 [-ScriptCommandSetting <SCScriptCommandSetting>] -ScriptType <ScriptCommandType> [-StandardInput <String>]
 [-TimeoutSeconds <Int32>] [-VMMServer <ServerConnection>] [<CommonParameters>]
Add-SCScriptCommand [-CommandParameters <String>] [-DeploymentOrder <Int32>] [-Executable <String>]
 [-JobGroup <Guid>] [-JobVariable <String>] [-LibraryResource <CustomResource>] [-PROTipID <Guid>]
 -PhysicalComputerProfile <PhysicalComputerProfile> [-RunAsAccount <VMMCredential>] [-RunAsynchronously]
 [-ScriptCommandSetting <SCScriptCommandSetting>] -ScriptType <ScriptCommandType> [-StandardInput <String>]
 [-TimeoutSeconds <Int32>] [-VMMServer <ServerConnection>] [<CommonParameters>]
Add-SCScriptCommand [-CommandParameters <String>] [-DeploymentOrder <Int32>] [-Executable <String>]
 [-JobGroup <Guid>] [-JobVariable <String>] [-LibraryResource <CustomResource>] [-PROTipID <Guid>]
 [-RunAsAccount <VMMCredential>] [-RunAsynchronously] [-ScriptCommandSetting <SCScriptCommandSetting>]
 -ScriptType <ScriptCommandType> [-StandardInput <String>] [-TimeoutSeconds <Int32>]
 [-VMMServer <ServerConnection>] [<CommonParameters>]

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.

Examples

Example 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.

Parameters

-ApplicationDeployment

Specifies an application deployment object.

Type:ApplicationDeployment
Required:True
Position:Named
Default value:None
Accept pipeline input:True (ByValue)
Accept wildcard characters:False
-ApplicationProfile

Specifies an application profile object.

Type:ApplicationProfile
Required:True
Position:Named
Default value:None
Accept pipeline input:True (ByValue)
Accept wildcard characters:False
-CommandParameters

Specifies the parameters for a script or executable program.

Type:String
Required:False
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-DeploymentOrder

Specifies the order in which a computer tier, application host, or application is deployed.

Type:Int32
Required:False
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-Executable

Specifies the name of an executable program.

Type:String
Required:False
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-JobGroup

Specifies an identifier for a series of commands that will run as a set just before the final command that includes the same job group identifier runs.

Type:Guid
Required:False
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-JobVariable

Specifies that job progress is tracked and stored in the variable named by this parameter.

Type:String
Required:False
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-LibraryResource

Specifies a resource stored in the Virtual Machine Manager (VMM) library.

Type:CustomResource
Required:False
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-PROTipID

Specifies the ID of the Performance and Resource Optimization tip (PRO tip) that triggered this action. This parameter lets you audit PRO tips.

Type:Guid
Required:False
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-PhysicalComputerProfile

Specifies a profile that is used to deploy an operating system to a computer.

Type:PhysicalComputerProfile
Aliases:VMHostProfile
Required:True
Position:Named
Default value:None
Accept pipeline input:True (ByValue)
Accept wildcard characters:False
-RunAsAccount

Specifies a Run As account that contains credentials with permission to perform this action.

Type:VMMCredential
Required:False
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-RunAsynchronously

Indicates that the job runs asynchronously so that control returns to the command shell immediately.

Type:SwitchParameter
Required:False
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-ScriptCommandSetting

Specifies a script command setting object.

Type:SCScriptCommandSetting
Required:False
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-ScriptType

Specifies a script type. The acceptable values for this parameter are:

- PreInstall

  • PostInstall
  • SaveState
  • RestoreState
  • PreService
  • PostService
  • PreUninstall
  • PostUninstall
  • OrderedCommand
  • BareMetalPostWinPERegistration
  • OnProvisionFirst
  • OnProvisionRest
  • OnDeleteLast
  • OnDeleteRest
  • Install
  • BareMetalPostDeployment

Type:ScriptCommandType
Parameter Sets:PreService, PostService, SaveState, RestoreState, PreInstall, PostInstall, PreUninstall, PostUninstall, OrderedCommand, BareMetalPostWinPERegistration, OnProvisionFirst, OnProvisionRest, OnDeleteLast, OnDeleteRest, Install, BareMetalPostConfiguration, BareMetalPostUnattend
Required:True
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-StandardInput

Specifies a path to a file that contains standard input information to use with the script command.

Type:String
Required:False
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-TimeoutSeconds

Specifies the amount of time, in seconds, that a process waits before timing out.

Type:Int32
Required:False
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-VMMServer

Specifies a Virtual Machine Manager (VMM) server object.

Type:ServerConnection
Required:False
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

Outputs

ScriptCommand

This cmdlet returns a **ScriptCommand** object.