从VirtualMachineManager模块运行Get-SCVirtualDiskDrive命令时,没有特别的方式。

Get-SCVirtualDiskDrive -VMMServer $VMMServer -VM $VMName

我收到特定于公共(public)语言(CLS)的错误

format-default:类型为“Microsoft.SystemCenter.VirtualMachineManager.VirtualDiskDrive”的字段或属性:“Lun”,仅与该字段的字母大小写不同
或属性:“LUN”。该类型必须符合公共(public)语言规范(CLS)。
+ CategoryInfo:未指定:(:) [format-default],ExtendedTypeSystemException
+ FullyQualifiedErrorId:NotACLSComplaintProperty,Microsoft.PowerShell.Commands.FormatDefaultCommand


我很难从网上可以找到的有关.NET和PowerShell的一些技巧中尝试使此命令正常工作

这行代码有效
$method1 = [Microsoft.SystemCenter.VirtualMachineManager.VirtualDiskDrive].GetMethod("get_LUN")

我真的希望这行代码返回某些内容,但不返回任何内容……
$method2 = [Microsoft.SystemCenter.VirtualMachineManager.VirtualDiskDrive].GetMethod("get_Lun")

除了使这条线起作用之外,脚本的目的还在于扩展虚拟机的主要VHD。我真的希望有人能在这里提供帮助,这不是我第一次遇到这个问题,但这一次,这是不可避免的。

最佳答案

问题是因为我正在运行Powershell版本4,而virtualmachinemanager模块仅与版本2兼容。

留下两个选择

  • 卸载窗口管理框架以将Powershell降级到版本2
  • 使用Start-Process以Powershell版本2的形式运行脚本

  • Start-Process-文件PowerShell.exe-参数“-Version 2 -noprofile -noexit -file test.ps1 $ params”

    不理想,我希望有人可以改善这个答案

    09-30 17:19
    查看更多