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
The error message will display as shown below
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):
Remove-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue