Invoke-SCScriptCommand
Runs a script command on the specified host.
Syntax
Invoke-SCScriptCommand
-VMHost <Host>
-Executable <String>
[-CommandParameters <String>]
[-ScriptCommandSetting <SCScriptCommandSetting>]
[-TimeoutSeconds <Int32>]
[-StandardInput <String>]
[-LibraryResource <CustomResource>]
[-RunAsAccount <RunAsAccount>]
[-VMMServer <ServerConnection>]
[-RunAsynchronously]
[-PROTipID <Guid>]
[-JobVariable <String>]
[<CommonParameters>]
Invoke-SCScriptCommand
-StorageFileServerNode <StorageFileServerNode>
-Executable <String>
[-CommandParameters <String>]
[-ScriptCommandSetting <SCScriptCommandSetting>]
[-TimeoutSeconds <Int32>]
[-StandardInput <String>]
[-LibraryResource <CustomResource>]
[-RunAsAccount <RunAsAccount>]
[-VMMServer <ServerConnection>]
[-RunAsynchronously]
[-PROTipID <Guid>]
[-JobVariable <String>]
[<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 |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-Executable
Specifies the name of an executable program.
Type: | String |
Position: | Named |
Default value: | None |
Required: | True |
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 |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-LibraryResource
Specifies a resource stored in the VMM library.
Type: | CustomResource |
Position: | Named |
Default value: | None |
Required: | False |
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 |
Position: | Named |
Default value: | None |
Required: | False |
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 |
Position: | Named |
Default value: | None |
Required: | False |
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 |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-ScriptCommandSetting
Specifies a script command setting object.
Type: | SCScriptCommandSetting |
Position: | Named |
Default value: | None |
Required: | False |
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 |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-StorageFileServerNode
Specifies a node in a file server cluster.
Type: | StorageFileServerNode |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-TimeoutSeconds
Specifies the amount of time, in seconds, that a process waits before timing out.
Type: | Int32 |
Position: | Named |
Default value: | None |
Required: | False |
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 |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-VMMServer
Specifies a VMM server object.
Type: | ServerConnection |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
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.