【问题标题】:How to run get-vm command on windows powershell如何在 Windows Powershell 上运行 get-vm 命令
【发布时间】:2013-01-04 07:16:51
【问题描述】:

我尝试在 windows powershell 上运行 get-vm 命令。它抛出了这个异常:

“脚本错误:‘Get-VM’一词未被识别为 cmdlet、函数、脚本文件或可运行的程序。检查 名称的拼写,或者如果包含路径,请验证路径 是正确的,然后再试一次。”

但我在系统中心 powershell 上运行相同的命令,它运行成功。但我需要在 windows powershell 上运行。我可以在 windows powershell 上运行它吗?

【问题讨论】:

  • 您是否正在运行 ps 2.0 试图远程控制 hyper-v 服务器?如果是这样,如果我没记错的话,你需要下载 RSAT 工具并激活“hyper-v powershell 模块”windows 功能

标签: powershell


【解决方案1】:

导入 VMM 管理单元。 System Center 的 Powershell 快捷方式默认加载它。 Vanilla Powershell 没有。

使用Get-PSSnapin -Registered 列出所有可用的管理单元。你要找的是Microsoft.SystemCenter.VirtualMachineManager

加载管理单元:Add-PSSnapin -Name Microsoft.SystemCenter.VirtualMachineManager

获取和设置默认 VMM 服务器:get-vmmserver myVMMServer.VMMServeror use-VMMServer` 开关以指定 cmdlet 将与之交互的 VMM 服务器。

【讨论】:

  • 感谢您的回答。我正在使用“Get-PSSnapin -Registered”powershell 显示“WDeploySnapin3.0”。我正在使用“Get-PSSnapin”我看到“Microsoft.Powershell.Core”但我在虚拟机管理器 powershell 控制台上运行 get-vm 命令没有抛出任何错误
  • 我找到了不同的解决方案。首先通过'Set-ExecutionPolicy RemoteSigned'将执行策略设置为RemoteSigned并通过'Import-Module "C:\Program Files\Microsoft System Center 2012\Virtual Machine Manager\bin\psModules\virtualmachinemanager\virtualmachinemanager.psd1" 导入虚拟机模块和我成功运行 get-vm 脚本。但是我用 c# 调用相同的脚本这个脚本不起作用。
猜你喜欢
  • 1970-01-01
  • 2018-03-14
  • 2019-05-09
  • 2018-10-12
  • 2020-02-05
  • 1970-01-01
  • 2022-01-17
  • 2018-05-05
  • 1970-01-01
相关资源
最近更新 更多