从 VirtualMachineManager 模块运行 Get-SCVirtualDiskDrive 命令时,没有特别的特殊方式。
Get-SCVirtualDiskDrive -VMMServer $VMMServer -VM $VMName
我收到公共(public)语言特定 (CLS) 错误
格式默认:字段或属性:“Lun”,类型:“Microsoft.SystemCenter.VirtualMachineManager.VirtualDiskDrive”仅在字母大小写方面与字段不同
或属性:“LUN”。该类型必须符合公共(public)语言规范 (CLS)。
+ CategoryInfo : NotSpecified: (:) [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 版。
留下两个选择
Start-Process -File PowerShell.exe -Argument "-Version 2 -noprofile -noexit -file test.ps1 $params"
不理想,我希望有人可以改进这个答案
关于.net - Powershell Get-SCVirtualDiskDrive 生成公共(public)语言规范 (CLR) 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32971483/