Thursday 4 April 2013

Configuring PowerGUI in SharePoint 2010!!

Hi all, as the post’s title suggest, this blog is all about Configuring the PowerGUI, tool in the SharePoint Environment. Last night,  we were about to deliver an urgent task. The task is to Create 3 more columns in the existing SharePoint lists. As we are having batch to accomplish this task, since we all knew about the worries in executing the batch. So, I thought of going PowerShell Way of accomplishing this task. As it involves, various site’s opening, within that various lists opening, the script will get a giant-size, In PS, the only problem is code maintainability., (that too scrolling up & down in a normal text-editor :( ).  So thought of using better editor, as per google’s first suggest, i intended to use thePowerGUI (so called my savior).
Before Using any tool, remember this quote,
“You have to learn the rules of the game. And then you play better than anyone else.”
this means have to configure the tool, before start using them. Hence the configuration goes as follows ::
1) Download the tool from the link ::https://powergui.org/downloads.jsp
2) Install it.
3) Open the tool & start using it (usually a sample Hello World script).
4) But our need is to configure them to SharePoint environment (or) we can say to enable SharePoint   CmdLets in PowerGUI.
1)  Open a command prompt with elevated permissions.
2)  Browse to C:\Windows\Microsoft.NET\Framework64\v2.0.50727
3)  Execute the InstallUtil.exe with the following command line parameters:
InstallUtil /LogToConsole=true C:\Windows\assembly\GAC_MSI\Microsoft.SharePoint.PowerShell\14.0.0.0__71e9bce111e9429c\Microsoft.SharePoint.Powershell.dll
5) All are working fine, but still we’ll get an annoying error, in the first step of using(yes that too with our familiar SPSite(“site-url”) object’s declaration :( ).
Error ::
“Microsoft SharePoint is not supported with version 4.0.21006.1 of the Microsoft.Net Runtime”.
Solution ::
If I got any errors (of type out-of-coverage) means, I’m having the habit of commenting that errr lines (mostly in web.config while hosting ;) ). Similarly, here too you can find the .config file named ScriptEditor.exe.config under the installed path, say “D:\Program Files (x86)\PowerGUI”
containing the lines ::
1.        <?xml version=”1.0″ encoding=”utf-8″ ?>
2.       <configuration>
3.       <startup useLegacyV2RuntimeActivationPolicy=”true”>
4.       <supportedRuntime version=”v4.0″ sku=”.NETFramework,Version=v4.0″ />
5.       <supportedRuntime version=”v2.0.50727″ />
6.       </startup> (vow, a smaller .config file for a beautiful tool. )
Try to comment the line 4 , for which version not supported 4.0 and Save.
Re-Open the tool and Continue, running your SP cmdlets with this tool.
Reason Behind ::
1) Based on the release notes of PowerGUI 3.2.0.2237 it seems they added .net 4.0 support natively. Not sure if it was supposed to be backwards compatible or not, but at first glance its not.
2) SP 2010 Object Model is built on .NET 3.5. This will not change. .NET 4.0 was not ready when building SharePoint 2010, so .NET 3.5 was the next best thing. Moreover, .NET 2.0 & .3.5 are based on same CLR but .NET 4.0 is having new CLR with DLR (Dynamic Language Runtime), a runtime environment that adds a set of services for dynamic languages to the CLR. Still, DLR is not yet having side-by-side execution.

No comments:

Post a Comment