在 Console App .Net Core 3.1 中使用以下代码{"The following exception occurred while retrieving member \"WithAuthority\": \"Could not load file or assembly 'System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. The system cannot find the file specified.\""}
执行 Powershell 命令时出现错误:Add-PowerAppsAccount -Username $user -Password $pass
using (PowerShell ps = PowerShell.Create())
{
ps.AddScript(query);
ps.AddParameters(prms);
var pipelineObjects = await ps.InvokeAsync().ConfigureAwait(false);
foreach (var item in pipelineObjects)
{
if (item != null)
Console.WriteLine(item.BaseObject.ToString());
else
Console.WriteLine("");
}
}
任何想法和意见将不胜感激。
注 1:代码在 PowerShell 7.0 中正常工作
注意 2:这将是未来的 Azure 函数。