Sharepoint automated backups via Powershell
Posted on 2012-03-29
I'm having a very strange issue. I am in the process of creating scripts to automate my backups in SharePoint 2010. My scripts work, I've ran them manually and it completes my backups. The problem I'm having is that they're failing when they're called via task scheduler. I can run power shell, open my ps1 file and run it, works great. But the issue is when it calls power shell via task scheduler, it says it can't add the snap in Error here:
Add-PSSnapin : No snap-ins have been registered for Windows PowerShell version
At line:1 char:13
+ add-pssnapin <<<< microsoft.sharepoint.powershell
+ CategoryInfo : InvalidArgument: (microsoft.sharepoint.powershel
l:String) [Add-PSSnapin], PSArgumentException
+ FullyQualifiedErrorId : AddPSSnapInRead,Microsoft.PowerShell.Commands.Ad
This makes absolutely ZERO sense considering I can navigate to the system 32 folder, and manually open power shell, and add this snap in successfully. In task scheduler I have it opening a the powershell.exe from the exact same path in the system 32 folder.
So I tested it, and had it open power shell with the no exit option, and tried manually adding the snap in, it fails. I'm not sure if it's getting confused because of permissions or what, but it's driving me crazy.
Also have the execution policy set to unrestricted.
A side note, if you're going to answer this, do not go to google and post any links that are within the first 5 results...because I've looked there.