0
몇 가지 Powershell 스크립트를 실행하는 앱이 있습니다. (기본적으로 SQL 데이터베이스에 저장된 일부 PS 스크립트를 가져 와서 실행하는 래퍼 응용 프로그램입니다.)C#에서 실행중인 PowerShell 코드의 runspace를 어떻게 설정할 수 있습니까?
내가 추가 한 Powershell 스크립트 중 하나가 지금 실패하고 있으며 필자가 필요로하기 때문에 느끼고 있습니다. STA 아파트 상태로 운영됩니다. 그러나 C#에서 아파트 상태를 설정하는 방법을 모르겠습니다.
다음과 같이 내가 사용하고있는 기능은 다음과 같습니다
public bool RunSomePowershell(string script)
{
using (PowerShell PowerShellInstance = PowerShell.Create())
{
PowerShellInstance.AddScript(script);
var result = PowerShellInstance.Invoke();
return Convert.ToBoolean(result[result.Count -1].ToString()); // Result should be last output from script (true or false)
}
}
어떻게이 STA 모드에서 스크립트를 실행하도록 설정할 수 있습니까?