Invoke-SCScriptCommand
在指定的主機上執行指令碼命令。
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
Invoke-SCScriptCommand Cmdlet 會在指定的主機上執行指令碼命令。 只有 Hyper-V 主機上才支援此 Cmdlet。
範例
範例 1:執行指令碼命令
PS C:\> $VMHost = Get-SCVMHost -ComputerName "VMHost01"
PS C:\> Invoke-SCScriptCommand -VMHost $VMHost -Executable "cmd.exe" -CommandParameters "/C rd C:\test" -TimeoutSeconds 60
第一個命令會取得名為 VMHost01 的主機物件,並將物件儲存在$VMHost變數中。
第二個命令會執行名為 cmd.exe 的可執行程式,並在儲存在 $VMHost 的主機上指定參數。 在此情況下, Invoke-SCScriptCommand 會從 VMHost01 上的 c: 磁片磁碟機中移除測試目錄。
參數
-CommandParameters
指定腳本或可執行程式的參數。
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-Executable
指定可執行程式的名稱。
Type: | String |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-JobVariable
指定追蹤工作進度,並將工作進度存放在這個參數命名的變數中。
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-LibraryResource
指定儲存在 VMM 程式庫中的資源。
Type: | CustomResource |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-PROTipID
指定觸發此動作 (PRO 提示) 效能和資源優化提示的識別碼。 此參數可讓您稽核 PRO 秘訣。
Type: | Guid |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-RunAsAccount
指定執行身分帳戶,其中包含具有執行此動作許可權的認證。
Type: | RunAsAccount |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-RunAsynchronously
表示作業會以非同步方式執行,讓控制項立即返回命令殼層。
Type: | SwitchParameter |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-ScriptCommandSetting
指定指令碼命令設定物件。
Type: | SCScriptCommandSetting |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-StandardInput
指定檔案的路徑,其中包含要與指令碼命令搭配使用的標準輸入資訊。
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-StorageFileServerNode
指定檔案伺服器叢集中的節點。
Type: | StorageFileServerNode |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-TimeoutSeconds
指定進程在逾時前等候的時間量,以秒為單位。
Type: | Int32 |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-VMHost
指定虛擬機器主機物件。 VMM 支援 Hyper-V 主機、VMware ESX 主機和 Citrix XenServer 主機。
如需每種主機類型的詳細資訊,請參閱 Add-SCVMHost Cmdlet。
Type: | Host |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-VMMServer
指定 VMM 伺服器物件。
Type: | ServerConnection |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
輸出
ScriptCommand
此 Cmdlet 會傳回 ScriptCommand 物件。
備註
- 需要可以使用Get-SCVMHost Cmdlet 擷取的VMHost物件。