Still in the process of implementing the Fenomen Platform (www.fenomen.pro) and especially the capability to generate applications for SharePoint and deploy them to SharePoint, I am generating and running PowerShell Scripts aiming at configuring SharePoint. I had the following issue:
When I run my script from a command shell, every goes fine. However when I had one of my applications launch the script, I ran into the following exception:
dd-PSSnapin : No snap-ins have been registered for Windows PowerShell version 2.At C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\CONFIG\POWERSHELL\Registration\sharepoint.ps1
I did some research and found out that the issue was that the 32 bit of PowerShell was launched instead of the 64 bits. That said, my script specifically calls the 64 bit version of PowerShell! (C:\Windows\System32\WindowsPowerShell\v1.0\PowerShell.exe)
The issue was that my application was built targeting x86 processors and thus ran in 32 bits. And the call to the 64bits version of PowerShell was therefore automatically redirected by the OS to the 32 bits version of PowerShell (C:\Windows\SysWOW64\WindowsPowerShell\v1.0)
Solution was to change the build options of my application to target x64 processors!