2015-10-06 26 views
1

從VirtualMachineManager模塊以毫無特別的方式運行Get-SCVirtualDiskDrive命令時。Powershell Get-SCVirtualDiskDrive生成通用語言規範(CLR)錯誤

Get-SCVirtualDiskDrive -VMMServer $VMMServer -VM $VMName 

我收到公共語言特定(CLS)錯誤

格式默認:該字段或屬性:「倫」類型:「Microsoft.SystemCenter.VirtualMachineManager.VirtualDiskDrive」在信唯一不同外殼 或屬性:「LUN」。該類型必須符合公共語言規範(CLS)。 + CategoryInfo:NotSpecified:(:) [格式默認],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。我真的希望有人能在這裏幫助,這不是我第一次遇到問題,但這一次,這是不可避免的。

回答

0

的問題是,因爲我運行PowerShell的版本4和virtualmachinemanager模塊僅compatiable最高版本爲2

留下兩個選項

  • 卸載窗口管理框架,以降低PowerShell來2版
  • 使用開始處理運行一個腳本Powershell的版本2

站RT-過程 - 文件PowerShell.exe -Argument 「-Version 2 -noprofile -noexit -file test.ps1 $ PARAMS」

不理想,我希望有人能改善這個答案