Add-SCScriptCommand

Applies To: System Center 2012 - Virtual Machine Manager

Add-SCScriptCommand

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

Syntax

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

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

Parameter Set: VMHostProfile
Add-SCScriptCommand -Executable <String> -VMHostProfile <VMHostProfile> [-CommandParameters <String> ] [-JobVariable <String> ] [-LibraryResource <CustomResource> ] [-PROTipID <Guid> ] [-RunAsynchronously] [-ScriptCommandSetting <SCScriptCommandSetting> ] [-StandardInput <String> ] [-TimeoutSeconds <Int32> ] [-VMMServer <ServerConnection> ] [ <CommonParameters>]

Detailed 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<ApplicationDeployment>

Specifies an application deployment object.

Aliases

none

Required?

true

Position?

named

Default Value

none

Accept Pipeline Input?

true (ByValue)

Accept Wildcard Characters?

false

-ApplicationProfile<ApplicationProfile>

Specifies an application profile object.

Aliases

none

Required?

true

Position?

named

Default Value

none

Accept Pipeline Input?

true (ByValue)

Accept Wildcard Characters?

false

-CommandParameters<String>

Specifies the parameters for a script or executable program.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Executable<String>

Specifies the name of an executable program.

Aliases

none

Required?

true

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-JobVariable<String>

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

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-LibraryResource<CustomResource>

Specifies a resource stored in the VMM library.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-PROTipID<Guid>

Specifies the ID of the PRO tip that triggered this action. This allows for auditing of PRO tips.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-RunAsAccount<VMMCredential>

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

Aliases

none

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.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-ScriptCommandSetting<SCScriptCommandSetting>

Specifies a script command setting object.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-ScriptType<ScriptCommandType>

Specifies a script type. Valid values are: PreInstall, PostInstall, SaveState, RestoreState, PreService, PostService, PreUninstall, PostUninstall.

Aliases

none

Required?

true

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-StandardInput<String>

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

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-TimeoutSeconds<Int32>

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

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-VMHostProfile<VMHostProfile>

Specifies a virtual machine host profile object.

Aliases

none

Required?

true

Position?

named

Default Value

none

Accept Pipeline Input?

true (ByValue)

Accept Wildcard Characters?

false

-VMMServer<ServerConnection>

Specifies a VMM server object.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

<CommonParameters>

This cmdlet supports the common parameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutBuffer, and -OutVariable. For more information, see about_CommonParameters.

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

Outputs

The output type is the type of the objects that the cmdlet emits.

  • ScriptCommand

Examples

1: Add a script command to an application profile.

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.

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

Get-SCScriptCommand

Remove-SCScriptCommand

Set-SCScriptCommand