Invoke-SCScriptCommand

Runs a script command on the specified host.

Syntax

Invoke-SCScriptCommand [-CommandParameters <String>] -Executable <String> [-JobVariable <String>]
 [-LibraryResource <CustomResource>] [-PROTipID <Guid>] [-RunAsAccount <RunAsAccount>] [-RunAsynchronously]
 [-ScriptCommandSetting <SCScriptCommandSetting>] [-StandardInput <String>]
 -StorageFileServerNode <StorageFileServerNode> [-TimeoutSeconds <Int32>] [-VMMServer <ServerConnection>]
 [<CommonParameters>]
Invoke-SCScriptCommand [-CommandParameters <String>] -Executable <String> [-JobVariable <String>]
 [-LibraryResource <CustomResource>] [-PROTipID <Guid>] [-RunAsAccount <RunAsAccount>] [-RunAsynchronously]
 [-ScriptCommandSetting <SCScriptCommandSetting>] [-StandardInput <String>] [-TimeoutSeconds <Int32>]
 -VMHost <Host> [-VMMServer <ServerConnection>] [<CommonParameters>]

Description

The Invoke-SCScriptCommand cmdlet runs a script command on the specified host. This cmdlet is only supported on Hyper-V hosts.

Examples

Example 1: Run a script command

PS C:\> $VMHost = Get-SCVMHost -ComputerName "VMHost01"
PS C:\> Invoke-SCScriptCommand -VMHost $VMHost -Executable "cmd.exe" -CommandParameters "/C rd C:\test" -TimeoutSeconds 60

The first command gets the host object named VMHost01 and stores the object in the $VMHost variable.

The second command runs the executable program named cmd.exe with the specified parameters on the host stored in $VMHost. In this case, Invoke-SCScriptCommand removes the test directory from the c: drive on VMHost01.

Parameters

-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
-Executable

Specifies the name of an executable program.

Type:String
Required:True
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 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
-RunAsAccount

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

Type:RunAsAccount
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
-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
-StorageFileServerNode

Specifies a node in a file server cluster.

Type:StorageFileServerNode
Required:True
Position:Named
Default value:None
Accept pipeline input:True (ByValue)
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
-VMHost

Specifies a virtual machine host object. VMM supports Hyper-V hosts, VMware ESX hosts, and Citrix XenServer hosts.

For more information about each type of host, see the Add-SCVMHost cmdlet.

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

Specifies a VMM server object.

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

Outputs

ScriptCommand

This cmdlet returns a **ScriptCommand** object.

Notes

* Requires a **VMHost** object, which can be retrieved by using the **Get-SCVMHost** cmdlet.