Share via


Add-SCScriptCommand

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

Syntax

ApplicationProfile

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

ApplicationDeployment

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

PhysicalComputerProfile

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

JobGroup

Add-SCScriptCommand
    -ScriptType <ScriptCommandType>
    [-Executable <String>]
    [-CommandParameters <String>]
    [-ScriptCommandSetting <SCScriptCommandSetting>]
    [-TimeoutSeconds <Int32>]
    [-StandardInput <String>]
    [-LibraryResource <CustomResource>]
    [-RunAsAccount <VMMCredential>]
    [-VMMServer <ServerConnection>]
    [-JobGroup <Guid>]
    [-DeploymentOrder <Int32>]
    [-RunAsynchronously]
    [-PROTipID <Guid>]
    [-JobVariable <String>]
    [<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.

Parameter properties

Type:ApplicationDeployment
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

ApplicationDeployment
Position:Named
Mandatory:True
Value from pipeline:True
Value from pipeline by property name:False
Value from remaining arguments:False

-ApplicationProfile

Specifies an application profile object.

Parameter properties

Type:ApplicationProfile
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

ApplicationProfile
Position:Named
Mandatory:True
Value from pipeline:True
Value from pipeline by property name:False
Value from remaining arguments:False

-CommandParameters

Specifies the parameters for a script or executable program.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-DeploymentOrder

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

Parameter properties

Type:Int32
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Executable

Specifies the name of an executable program.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments: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.

Parameter properties

Type:Guid
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

PhysicalComputerProfile
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False
JobGroup
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-JobVariable

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

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-LibraryResource

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

Parameter properties

Type:CustomResource
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-PhysicalComputerProfile

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

Parameter properties

Type:PhysicalComputerProfile
Default value:None
Supports wildcards:False
DontShow:False
Aliases:VMHostProfile

Parameter sets

PhysicalComputerProfile
Position:Named
Mandatory:True
Value from pipeline:True
Value from pipeline by property name:False
Value from remaining arguments: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.

Parameter properties

Type:Guid
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-RunAsAccount

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

Parameter properties

Type:VMMCredential
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-RunAsynchronously

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

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-ScriptCommandSetting

Specifies a script command setting object.

Parameter properties

Type:SCScriptCommandSetting
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments: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

Parameter properties

Type:ScriptCommandType
Default value:None
Accepted values:PreService, PostService, SaveState, RestoreState, PreInstall, PostInstall, PreUninstall, PostUninstall, OrderedCommand, BareMetalPostWinPERegistration, OnProvisionFirst, OnProvisionRest, OnDeleteLast, OnDeleteRest, Install, BareMetalPostConfiguration, BareMetalPostUnattend
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-StandardInput

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

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-TimeoutSeconds

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

Parameter properties

Type:Int32
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-VMMServer

Specifies a Virtual Machine Manager (VMM) server object.

Parameter properties

Type:ServerConnection
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

Outputs

ScriptCommand

This cmdlet returns a ScriptCommand object.