我只是尝试使用pssession在远程计算机上执行程序:
Invoke-Command -Session $ session -ScriptBlock {cd c:\ 电源外壳; Invoke-WmiMethod -path win32_process -name create -argumentlist $ arra Y}
我的参数数组如下所示:
$array
c:\powershell\sqbconverter.exe
d:\Restore\xxxx\FULL_(local)_xxxx_PROD_20131016_230001.sqb
D:\Restore\xxxx\full\Restore_xxxx_full.bak
xxxxxx
结果如下:
PSComputerName : hostname1
RunspaceId : 92656a18-ca0f-4684-aff2-086f109fce59
PSShowComputerName : True
__GENUS : 2
__CLASS : __PARAMETERS
__SUPERCLASS :
__DYNASTY : __PARAMETERS
__RELPATH :
__PROPERTY_COUNT : 2
__DERIVATION : {}
__SERVER :
__NAMESPACE :
__PATH :
ProcessId :
ReturnValue : 21
我不确定如何调试远程计算机上究竟发生了什么,但我没有得到我想要的输出( exe应该创建一个输出文件)。非常感谢任何帮助,谢谢。
答案 0 :(得分:0)
您需要将$array
注入您传递给Invoke-Command
的脚本块,例如:
Invoke-Command -Session $session -ScriptBlock {param($arr)
cd c:\ powershell
Invoke-WmiMethod Win32_Process -Name create -ArgumentList $arr} -Arg $array