RSS Feed
LinkedIn
Delicious
Skip to main content

Cornelius J. van Dyk's SharePoint Brain Dump

Rate this blog:
Go Search
Home
Step-by-Step Guides
Downloads
Post Archive
Capacity Planning
Architecture & Topology
Support Forums
SharePoint Team Blog
  

Cornelius J. van Dyk's SharePoint Brain Dump > Categories
How do I - Resolve the failure to load a module into PowerShell when using the Import-Module cmdlet

If you've ventured into the world of PowerShell extensions and modules, and more specifically, that world, targeted at SharePoint, then you have probably run into this error before.

Import-Module : Could not load file or assembly 'file:///C:\cjvandyk.SharePoint.PowerShell.dll' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded. At line:1 char:14+ import-module <<<< .\cjvandyk.SharePoint.PowerShell.dll + CategoryInfo: NotSpecified: (:) [Import-Module], BadImageFormatException + FullyQualifiedErrorId : System.BadImageFormatException,Microsoft.PowerShell.Commands.ImportModuleCommand

This error is thrown by PowerShell when you are using the Import-Module cmdlet to import a PowerShell module (redundant, isn't it?) that was built using the .NET Framework 4.0.  The ugly error looks like this:

image

If you're trying to use that module on a SharePoint system, the odds are that the server does NOT have the 4.0 version of the Framework installed.  You can easily confirm this by simply checking the sub folders under the C:\Windows\Microsoft.NET\Framework location.

 image

In the above example, you can see that 1.0, 1.1, 2.0, 3.0, 3.5 and 4.0 are all installed on the server.  If you find that 4.0 is NOT installed, you can quickly install it following this guide.

Once it's installed you only have one more thing left to do.  By default, PowerShell will run under the 2.0 Framework.  We need to force it to default to the 4.0 Framework and only revert back to 2.0 if it doesn't find what it's looking for in 4.0.

That is easily done using a .config file for the PowerShell executable.  Browse to the C:\Windows\System32\WindowsPowerShell\v1.0 location.

image

You may not have the two .config file on your system.  If you don't, you need to create them manually.  Name the files exactly the same as the .exe files, but with a .config extension at the back.  Create them as text files, but you will need to show extensions from your Folder Options in Windows Explorer in order to get rid of the .txt extension.  The two config files should be named "PowerShell.exe.config" and "PowerShell_ise.exe.config".  The content of the two files is a simple XML snippet that simply points PowerShell to default to 4.0 and fallback to 2.0.  Copy and paste the following snippet into the .config files.

<?xml version="1.0"?>
<configuration>
  <startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v4.0.30319"/>
    <supportedRuntime version="v2.0.50727"/>
  </startup>
</configuration> 

Now when you restart PowerShell, attempting to load your module should yield no errors (if your module is compiled correctly and valid), and you should be able to implement the functionality from the module without any problem.


Enjoy
C

Installing the .NET Framework 4.0 on your Windows Server 2008 R2 x64 server with SharePoint 2010

As we all know, SharePoint 2010 is still using the .NET Framework 3.5.  That means that your servers may not have the latest .NET Framework 4.0 installed.  This could cause some issues if you're trying to use APIs from 4.0, or if you are trying to build some new tools using 4.0, like PowerShell management extensions for example.  The solution is to install 4.0 on your server.  Here's the quick Step-by-Step for doing this on a Windows Server 2008 R2 x64 system with SharePoint 2010 installed.

  1. Begin by downloading the full version of the Framework from here:  http://www.microsoft.com/downloads/details.aspx?FamilyID=0a391abd-25c1-4fc0-919f-b21f31ab88b7&displaylang=en
  2. Once downloaded, double click the installer file named "dotnetFx40_Full_x86_x64.exe".

    image

  3. Windows may require you to confirm that you wish to launch the EXE.  If it does, simply click "Run".

    image

  4. You'd have to accept the EULA.  Check the "I have read and accept the license terms" check box.
  5. Click the "Install" button to commence the installation.

    image

  6. The installer will crunch away for a while as it installs the Framework.

    image

  7. Once installation complete, click the "Finish" button.

    image

  8. No server restart is needed. :-)

Later
C

How do I - Delete my SharePoint Shared Service Provider (SSP) when it fails to delete with STSADM

When you enter

STSADM -o deletessp

from your SharePoint web server command line, you should get this:

image

If you then proceed to try and delete your SSP with a command such as

STSADM -o deletessp –title SharedServices1

but it still fails to delete, then you could use the undocumented -force flag thus:

STSADM -o deletessp –title SharedServices1 -force

Which should yield this:

image

 

Gotta love those little –force flags.

Later
C

Technorati Tags: ,

How do I - Increase the SharePoint Foundation site template size limit

This one was undocumented in SharePoint 2007 / WSS 3.0 and is still undocumented in SharePoint 2010 / SPF.  I posted about this back in 2007 for the previous version, but was asked the same question in the SharePoint Support Forums.  A little digging and firing off a test confirmed that the command has stayed intact for the latest version as well.  Using STSADM from a command windows:

STSADM -o setproperty -pn max-template-document-size -pv 524288000

Let it run and upon completion, you should see this:

image

Later
C

Technorati Tags:

FOLLOW ME:

How do I – Move my SharePoint databases from a 32 bit Windows Server 2003 x86 with SQL Server 2005 x86 to a new SQL instance on a 64 bit Windows Server 2008 R2 x64 with SQL Server 2008 R2 x64

As part the migration plan for a major customer of mine, we had a phase scheduled to move the backend databases from 32 bit Windows Server 2003/SQL Server 2005 to 64 bit Windows Server 2008 R2/SQL Server 2008 R2.  This brought back to light the question of how to move your content to a new SQL Server.  There are many good articles out there, but this worked well for us.

http://www.cjvandyk.com/blog/Articles/How-do-I---Move-my-SharePoint-databases-from-32-bit-SQL-Server-2005-x86-to-a-new-Instance-on-64-bit-SQL-Server-2008-R2-x64.aspx

Later
C

FOLLOW ME:

How-do-I---Stop-the-double-logon-prompt-when-opening-a-document-in-SharePoint-document-libraries

I get this one a LOT in the support forums and the answer is quite simple.  I finally got tired to typing out the steps and decided to put together a quick Article for it.

http://www.cjvandyk.com/blog/Articles/How-do-I---Stop-the-double-logon-prompt-when-opening-a-document-in-a-SharePoint-document-library.aspx

Enjoy
C

Technorati Tags: ,

FOLLOW ME:

How do I - Get a list of all databases attached to my SQL Server 2008 R2 database server

Another quick one…  You can run this stored procedure:

exec sp_databases

Which should yield the following output:

image

or you could try this stored procedure:

exec sp_helpdb

Which would yield some more extended information thus:

image

or if you just want the names, you could execute this “undocumented” stored procedure:

exec sp_msforeachdb 'print ''?'''

Which will yield this:

image

Or you could do the manual step of executing the following select query:

select name from sys.databases

Which will yield:

image

 

Enjoy
C

FOLLOW ME:

Creating a HTML Redirect page

Every so often, you run across the need to redirect a page somewhere else, like after a server migration when DNS isn’t used.  By simply adding a HTTP-EQUIV meta tag to the <HEAD> of your page, you can redirect elsewhere in a jiffy.  Syntax isn’t complex, but must be correct to function properly.  Here’s the syntax:

<HTML>
<HEAD>
<META HTTP-EQUIV="refresh" CONTENT="SECONDS_HERE;URL=REDIRECT_URL_HERE">
</HEAD>
<BODY>
</BODY>
</HTML>


Later
C

Technorati Tags:

FOLLOW ME:



How do I - Install PowerPivot into an EXISTING SharePoint 2010 farm

This one was a BEAR to work through.  There’s not much out there for it and everywhere I turned it seems everyone else was either having the same problem OR suggestion we “start with a clean install”.  Nice suggestion that last one.  Almost like… try rebooting the computer… but I digress.  With three simple hacks, the install can be “guided” to complete successfully.  So hopefully this guide will help some other poor soul save some time when they run into the same issue.

Read the article here: 

http://www.cjvandyk.com/blog/Articles/How%20do%20I%20-%20Install%20PowerPivot%20into%20an%20EXISTING%20SharePoint%202010%20farm.aspx

I hope this saves somebody some time and frustration out there.

Later
C

FOLLOW ME:

Step-by-Step - Installing the Microsoft Access Database Engine 2010 Redistributable

This is a prerequisite to Installing PowerPivot for SharePoint into an EXISTING SharePoint Farm.  PowerPivot seems to work just fine being installed together with a clean install of SharePoint, but when you already have SharePoint installed and try to add PowerPivot… all hell breaks loose.  I was never able to find proper documentation on how to pull this off and managed to hack and debug my way through it like Holmes unraveling a mystery.  Hopefully this will save someone else some time and frustration…

Read the full article here:

http://www.cjvandyk.com/blog/Articles/Step-by-Step%20-%20Installing%20the%20Microsoft%20Access%20Database%20Engine%202010%20Redistributable.aspx

 

FOLLOW ME:

1 - 10 Next