【发布时间】:2013-03-19 13:26:31
【问题描述】:
我正在尝试从我的 Hyper-V 主机收集一些信息。我有一大堆,想自动化这个过程。 我需要获取在每个主机上运行的虚拟机。 我想从批处理脚本中做到这一点。 当我在 PowerShell V1.0 窗口(在 Hyper-V 主机上)中运行此命令时,它可以工作并为我提供必要的信息:
get-vmmemory | select VMelementName,reservation | out-file c:\Output.txt
这就是我从批处理脚本运行它的方式:
\\<RemoteMachine>\c$\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -command get-vmmemory >>aa.txt
这是我得到的输出
The term 'get-vmmemory' is not recognized as the name of a cmdlet, function,
script file, or operable program. Check the spelling of the name, or if a path
was included, verify that the path is correct and try again.
At line:1 char:16
+ & {get-vmmemory <<<< }
+ CategoryInfo : ObjectNotFound: (get-vmmemory:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
有人知道为什么我一直得到这个输出吗?
【问题讨论】:
-
试试这个:
start "" "c:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" ....
标签: powershell scripting batch-file hyper-v