Link to home
Start Free TrialLog in
Avatar of ded2545
ded2545Flag for United States of America

asked on

Sharepoint automated backups via Powershell

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
2.
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
   dPSSnapinCommand\

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.
Avatar of Justin Smith
Justin Smith
Flag of United States of America image

How are you calling the script from the task?
Avatar of ded2545

ASKER

I'm attaching a screen shot of what I have in task scheduler.  Keep in mind, it's a 3rd party task scheduler.  Which shouldn't make a difference, does the same thing in windows task scheduler.
Waiting for that screen....
Avatar of ded2545

ASKER

Sorry about that...
sharepoint-task.JPG
No .ps1 at the end of the file?
ASKER CERTIFIED SOLUTION
Avatar of Justin Smith
Justin Smith
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ded2545

ASKER

The batch file seems to be working, thanks!  Big fail on the MS book on automating this I guess!  Their way doesn't seem to work AT all!