Invoke-SCScriptCommand
Applies To: System Center 2012 - Virtual Machine Manager
Invoke-SCScriptCommand
Runs a script command on the specified host.
Syntax
Parameter Set: VMHost
Invoke-SCScriptCommand -Executable <String> -VMHost <Host> [-CommandParameters <String> ] [-LibraryResource <CustomResource> ] [-RunAsAccount <RunAsAccount> ] [-ScriptCommandSetting <SCScriptCommandSetting> ] [-StandardInput <String> ] [-TimeoutSeconds <Int32> ] [-VMMServer <ServerConnection> ] [ <CommonParameters>]
Detailed 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
-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 |
-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 |
-RunAsAccount<RunAsAccount>
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 |
-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 |
-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 |
-VMHost<Host>
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.
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? |
true (ByValue) |
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
Notes
- Requires a VMHost object, which can be retrieved by using the Get-SCVMHost cmdlet.
Examples
1. Run a script command.
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.
PS C:\> $VMHost = Get-SCVMHost -ComputerName "VMHost01"
PS C:\> Invoke-SCScriptCommand -VMHost $VMHost -Executable "cmd.exe" -CommandParameters "/C rd C:\test" -TimeoutSeconds 60