我正在使用点网版本4.5和SCVMM 2012 R2。尝试在以下代码下运行
InitialSessionState initial = InitialSessionState.CreateDefault();
initial.ImportPSModule(new string[] { "C:\\Program Files\\Microsoft System Center 2012 R2\\Virtual Machine Manager\\bin\\psModules\\virtualmachinemanager\\virtualmachinemanager.psd1" });
Runspace runspace = RunspaceFactory.CreateRunspace(initial);
runspace.Open();
PowerShell ps = PowerShell.Create();
ps.Runspace = runspace;
ps.Commands.AddCommand("Get-SCVMMserver");
ps.AddParameter("ComputerName", "some.domain.com");
foreach (PSObject result in ps.Invoke())
{
Console.WriteLine(result.Members["IsSupported"].Value);
}
它始终会由于以下错误而失败,
加载扩展类型数据文件时发生以下错误: Microsoft.PowerShell,C:\ Program Files \ Microsoft系统中心2012> R2 \ Virtual Machine Manager \ bin \ virtualmachinemanager.types.ps1xml(5):错误>输入“ Microsoft.SystemCenter.VirtualMachineManager.VMCheckpoint”:>异常:无法转换>“ Microsoft.SystemCenter.VirtualMachineManager.Cmdlets.VMCheckpointConverter” 类型为“ System.String”的值,以类型为“ System.Type”。 Microsoft.PowerShell,C:\ Program Files \ Microsoft系统中心2012> R2 \ Virtual Machine Manager \ bin \ virtualmachinemanager.types.ps1xml(11):>类型“ Microsoft.SystemCenter.VirtualMachineManager.Task”中的错误:>异常:无法将类型为“ System.String”的>“ Microsoft.SystemCenter.VirtualMachineManager.Cmdlets.TaskConverter”值转换为类型“ System.Type”。
请帮助我这个错误。谢谢
答案 0 :(得分:0)
错误消息显示public interface IQueryBus
{
Task<TResponse> ResolveAsync<TResponse>(IQuery<TResponse> query);
}
,只需将第2行从Cannot convert the >"Microsoft.SystemCenter.VirtualMachineManager.Cmdlets.TaskConverter" value >of type "System.String" to type "System.Type".
更改为string[]
,我认为应该没事。
new[]