Из командной строки могу.
.\test.ps1 1
Как передать параметр при этом из C #? Я пробовал
.AddArgument(1)
.AddParameter("p", 1)
И я пробовал передавать значения как IEnumerable
namespace ConsoleApplication1
{
using System;
using System.Linq;
using System.Management.Automation;
class Program
{
static void Main()
{
// Contents of ps1 file
// param($p)
// "Hello World ${p}"
var script = @".\test.ps1";
PowerShell
.Create()
.AddScript(script)
.Invoke().ToList()
.ForEach(Console.WriteLine);
}
}
}