Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have created timer job and under execute method.i have added below statement to run sharepoint command.

runspace.RunspaceConfiguration.AddPSSnapIn("Microsoft.SharePoint.PowerShell", out snapInError);

but i am receiving error wherever this code is getting executed.

Cannot load Windows PowerShell snap-in Microsoft.SharePoint.PowerShell because of the following error: Could not load file or assembly 'file:///C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Microsoft.SharePoint.PowerShell\v4.0_15.0.0.0__71E9BCE111E9429C\Microsoft.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.

Please help my requirement is to create timer job which will run my custom powerShell script

share|improve this question
    
If this is 2010, then the problem is that SP 2010 uses .Net 3.5 and the commandlet seems to use 4.0 –  Robert Lindgren Feb 28 at 11:36
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.