You can use the PowerShell class available in the Microsoft.PowerShell.Commands.Management namespace to invoke a PowerShell script with parameters from a C# application. Here's an example:
main.cs1164 chars38 linesIn the example above, replace C:\Scripts\MyScript.ps1 with the path to your PowerShell script file, and Param1, Value1, Param2, and Value2 with your actual script parameters. Make sure to set the execution policy to Unrestricted so that the script can run.
Note that the above example runs the script with the current user's permissions. If you need to run the script with elevated permissions, you will need to launch the C# application as an administrator.
gistlibby LogSnag