It’s unclear what you trying to achieve, but:
- The programm exits on the first error, hence the second command is not called
- Your code throws an error, because
Test1
was not found, and I’d assumeTest2
woudn’t be found, too - The script, or command must exist
Example:
PowerShell ps = PowerShell.Create();
ps.AddScript(“D:\PSScripts\MyScript.ps1”).Invoke();
More see Adding and invoking commands
2
solved I need to execute a powershell script from C# and “type in” a response when the program prompts me