Run powershell commands in C# Run powershell commands in C# powershell powershell

Run powershell commands in C#


Add this command first:

Add-PSSnapin Microsoft.SharePoint.Powershell -EA 0


You must use the import-module command to load the correct module for sharepoint. Use get-module to find available modules.

To do this programmatically, see my post on the subject:

http://www.nivot.org/2010/05/03/PowerShell20DeveloperEssentials1InitializingARunspaceWithAModule.aspx

-Oisin


I have this issue recently. In my case I was neither able to see the added solution nor able to add solution. So first I remove solution using below PowerShell Command:

(Get-SPSolution -Identity "YourSolution.wsp").Delete()

Then I was able to add my new code solution.