问题描述
我正在尝试通过 ASP.NET C# 代码运行 powershell 脚本。这是代码 -
Runspace runspace = RunspaceFactory.CreateRunspace();
runspace.open();
Command cmd = new Command(filePath); //filePath is the ps1 script file
parameters.ForEach(p => cmd.Parameters.Add(p.Key,p.Value));
pipeline = runspace.CreatePipeline();
pipeline.Commands.Add(cmd);
pipeline.Output.DataReady += Output_DataReady;
pipeline.Error.DataReady += Error_DataReady;
pipeline.StateChanged += Pipeline_StateChanged;
Collection<PSObject> results = pipeline.Invoke(); // This is where the exception gets thrown
runspace.Close();
当我尝试使用任何 Az 命令运行基本的 powershell 脚本时出现错误,例如 Connect-AzAccount
给我错误 -
来自程序集“Microsoft.Azure.PowerShell.Clients.ResourceManager,Version=1.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35”的“Microsoft.Azure.Management.Internal.Resources.ResourceManagementClient”类型中的方法“get_SerializationSettings”没有实现。”
经过检查,我运行它的 VM 只包含 Az 模块,没有 AzureRm 模块。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)