Reputation: 930
How do I invoke a powershell script from C# without using the Powershell class.
If I cannot use Process class what do I need to do.
Upvotes: 0
Views: 193
Reputation: 68331
If the script already exists as a file, you can use the Process class to start Powershell, and give it the file name as a command line argument.
Upvotes: 0
Reputation: 5822
why wouldnt you be able to use the process class? That really is the option you have to execute some commands, unless there is a form of a C# API available for powershell....
http://msdn.microsoft.com/en-us/library/system.management.automation.powershell(v=vs.85).aspx
a sample: http://msdn.microsoft.com/en-us/library/ee706564(v=vs.85).aspx
Upvotes: 2