Invoke-SCScriptCommand

Runs a script command on the specified host.

Description

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

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

Parameters

Executable

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

VMHost

Required? true
Accept Pipeline Input? true (ByValue)
Position? named
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, type: "Get-Help Add-SCVMHost -detailed". See the examples for a specific cmdlet to determine how that cmdlet uses this parameter.

CommandParameters

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

LibraryResource

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

RunAsAccount

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

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? true (ByValue)
Position? named
Specifies a VMM server object.
Requires a VMHost object, which can be retrieved by using the Get-SCVMHost cmdlet.

Examples

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.

See Also