.net Powershell Get-SCVirtualDiskDrive生成公共语言规范(CLR)错误
从VirtualMachineManager模块运行Get-SCVirtualDiskDrive命令时,没有特别的方式.net Powershell Get-SCVirtualDiskDrive生成公共语言规范(CLR)错误,.net,powershell,virtual-machine,clr,virtualization,.net,Powershell,Virtual Machine,Clr,Virtualization,从VirtualMachineManager模块运行Get-SCVirtualDiskDrive命令时,没有特别的方式 Get-SCVirtualDiskDrive -VMMServer $VMMServer -VM $VMName 我收到一个特定于公共语言(CLS)的错误 格式默认值:类型“Microsoft.SystemCenter.VirtualMachineManager.VirtualDiskDrive”的字段或属性“Lun”与字段的大小写不同 或属性:“LUN”。类型必须符合公共语
Get-SCVirtualDiskDrive -VMMServer $VMMServer -VM $VMName
我收到一个特定于公共语言(CLS)的错误
格式默认值:类型“Microsoft.SystemCenter.VirtualMachineManager.VirtualDiskDrive”的字段或属性“Lun”与字段的大小写不同
或属性:“LUN”。类型必须符合公共语言规范(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,VirtualMachine Manager模块只能兼容到版本2 留下两个选择
- 卸载窗口管理框架以将Powershell降级为版本2
- 使用启动进程以Powershell版本2的形式运行脚本