Scandals of an ITian

Not just another Wordpress Site

SharePoint 2010 – Troubleshooting Cmdlets not recognized Issue

While automating a lot of my SharePoint builds I came across this issue across while provisioning a few service applications within SharePoint 2010. Usually the culprits were:-

Access Service Application

Word Automation Service Application

Excel Service Application

Visio Service Application.

 

This morning, the usual suspects were back except Word Automation Service. After a few VM resets and restart of scripts, I found the culprit to be PowerShell loading up its cmdlets properly so that those executions happen properly.

The cmdlets that will usually fail are

Get-SPExcelServiceApplication

Get-SPVisioServiceApplication

New-SPVisioServiceApplication

New-SPExcelServiceApplication

New-SPAccessServiceApplication

 

The error message will display as shown below

 

Resolution:

 

Add these two lines to the beginning of your script ,

 

So if you’ve previously loaded your cmdlets the following code should be sufficient (add this to your own function or whatever):

1
2
3
Remove-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

Related posts:

  1. SharePoint 2010 – Central Admin – Command Search Web Part

, , , , , , , , , , , ,

  • Eric Schrader

    HAS TO COME AFTER CREATING OR JOINING THE FARM http://it-andy.com/post/2010/09/17/cmdlet-not-recognized.aspx

    I tried before creating my farm and it was still getting the same error. Did it once before and once after creating my farm and it worked!

  • Eric Schrader

    Actually, that didnt work either.

  • Anonymous

    @google-bf2b6fdc541765bd23f84bf0620bfeff:disqus  hey I have always had the trouble during my single installer scripts before it starts Word Automation , Excel Services Installation.

    I now create all my service applications separably under one script which forces me to open a new session of PowerShell and also reload the SharePoint Cmndlets once more… 

    just add this add this at he begining of all your sharepoint scripts Add-PSSnapin Microsoft.SharePoint.PowerShell -erroraction SilentlyContinue

    Also if you SharePoint Management Shell you could probably avoid this error completely as well. 

    Cheers

    and many thanks for your comments