I do an automatic installation of the solution in SharePoint, I went along the simplest, as it seemed to me, ways:
I unpack PowerShell script, solution and .cmd from embedded resources in .exe,
I cause start of .cmd.
When you start it manually, everything works, when you call from the collected .exe, it does not see the SP snap-ins. Simplified the task before calling ONLY PowerShell from C # - and here is incomprehensible to me:
add-pssnapin microsoft.sharepoint.powershell
The snap-in microsoft.sharepoint.powershell Windows PowerShell is not installed on this computer.
At the same time, in the next PowerShell window, the same team quietly fulfills.
The user is the same (checked with commands), the profile (now empty) also leads to one file when trying to call notepad $ profile (there was a hope to add a snapin connection there, it did not help). What can be done?
If this is important, I start PS (and before that .cmd) through the process:
var process = new ProcessStartInfo(); process.FileName = "powershell.exe"; Process.Start(process).WaitForExit();
