Hi All,
We have a plugin, on installation of this plugin, we have an "exe" which will add and deploy the solution(.wsp files) in central configuration site. On Un - installation of the plugin, the exe will deactivate the activated features related to our
plugin, retract the solution and finally remove the solution. This plugin will be installed in all web front ends.
For performing the above operation, we can use PowerShell commands or SharePoint APIS (as STSADM is deprecated, I am not including that). May I know the best way to do the same?
PowerShell commands:
There are two ways in this also
- Passing the PowerShell commands to System.Diagnostics.Process
ProcessStartInfo pInfo = new ProcessStartInfo("<PowerShellExePath>", "<ScriptToExecute or Powershell File Name");
Process process = new Process();
process.StartInfo = pInfo;
process.Start()
2. Runspace API
Runspace runspace = RunspaceFactory.CreateRunspace(InitialSessionState.CreateDefault());
runspace.Open();
PowerShell powerShellCommand = PowerShell.Create();
powerShellCommand.Runspace = runspace;
powerShellCommand.AddScript("Add-PsSnapin Microsoft.SharePoint.PowerShell");
powerShellCommand.AddScript(script);
powerShellCommand.Invoke<string>();
SharePoint APIs
Microsoft.SharePoint.Administration.SPFarm.Local.Solutions.Add or Microsoft.SharePoint.Administration.SPFarm.Local.Solutions.Remove].
Thanks & Regards,
Kalai.