Thursday, 20 September 2012

[ERROR FIX:] The term ‘Add-SPSolution ’ is not recognized as the name of a cmdlet, function, script file, or operable program.


I. PROBLEM

For my today’s task, my onshore counterpart has given me a backup file (.bak) to restore on a new site collection. So I have decided to do a restore script in Powershell to accomplish this job.  I was about to run my script in Powershell, when I came across this error. .

“The term ‘Add-SPSolution ’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.”



I thought that Powershell can automatically interpret Microsoft. Sharepoint.Powershell commands, but I was wrong.

II. SOLUTION

On top of your powershell script, add a code to reference Microsoft.Sharepoint.Powershell so it will be made available to Powershell ISE.
Add the line below at the start of your powershell script.

Add-PSSnapin Microsoft.Sharepoint.Powershell –EA 0

But for a long-term solution, so you do not have to constantly adding the above line every time you write a script, you may refer to the site below.

http://blogs.msdn.com/b/kaevans/archive/2011/11/14/add-microsoft-sharepoint-powershell-snap-in-to-all-powershell-windows.aspx



No comments:

Oscar L. Barit Jr. "I am Oca, i am writing to share with you some sharepoint matters that i learned on my day job. Enjoy! Mwah Mwah Tsup Tsup! "