InvalidData Error

I created a new script containing the line below and clicked Debug.

$spweb = Get-SpWeb http://myweb
Boom…  I was met with this in the Console:
Get-SPWeb : Microsoft SharePoint is not supported with version 4.0.30319.239 of the Microsoft .Net Runtime.
At C:\Users\MyUser\Documents\slk.ps1:2 char:19
+ $spweb = Get-SpWeb <<<<  http://myweb
+ CategoryInfo          : InvalidData: (Microsoft.Share….SPCmdletGetWeb:SPCmdletGetWeb) [Get-SPWeb], PlatformNotSupportedException
+ FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletGetWeb

Hmm, I guess I either need to 1) allow the SharePoint Cmdlets to run under .NET 4, 2) find an older version of PowerGUI, or 3) run PowerGUI under .NET 3.5. I chose option 3.

After some digging, I found the already-existant ScriptEditor.exe.config file inC:\Program Files (x86)\PowerGUI.

I opened it up with NotePad++ and noticed the following line:
<supportedRuntime version=”v4.0″ sku=”.NETFramework,Version=v4.0″ />
And promptly commented it out and saved the file.
<!– <supportedRuntime version=”v4.0″ sku=”.NETFramework,Version=v4.0″ /> –>

Next, I started up PowerGUI and was able to run the same SharePoint cmdlet.

Advertisements

One thought on “InvalidData Error

  1. Pingback: VS: PowerGui Vsx « RaSor's Tech Blog

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s