Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.net Powershell Get-SCVirtualDiskDrive生成公共语言规范(CLR)错误_.net_Powershell_Virtual Machine_Clr_Virtualization - Fatal编程技术网

.net Powershell Get-SCVirtualDiskDrive生成公共语言规范(CLR)错误

.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”。类型必须符合公共语

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

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的形式运行脚本
启动进程-文件PowerShell.exe-参数”-版本2-noprofile-noexit-文件test.ps1$params”

不太理想,我希望有人能改进这个答案