I asked this on ServerFault, but didn’t get any reply’s, I know it’s command line, but they should still be able to answer it, anyone here have any idea’s?
I’ve ran the following (task description):
> Add-PsSnapin Microsoft.SharePoint.Powershell
> Backup-SPFarm -Directory E:\Backups -BackupMethod Full
But get this error:
Backup-SPFarm : Object reference not set to an instance of an object.
At line:1 char:14
+ Backup-SPFarm <<<< -Directory \\SHAREPOINTSERV\Backups -BackupMethod full
+ CategoryInfo : InvalidData: (Microsoft.Share...mdletBackupFarm:SPCmdletBackupFarm) [Backup-SPFarm], NullReferenceException
+ FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletBackupFarm
I can backup manually through the Admin site, so all the services/permissions are setup correctly.
I can’t find much helpful info on this does anyone know why I’m getting this error message?
- running SQL Server 2008 R2 and Win2008 Standard (x64).
- tried setting the directory to a UNC path and a local path.
- tried
set-executionpolicy ByPass(and RemoteSigned) - I’m logged on as a user with enterprise admin security credentials
- SharePoint & SQL Server are installed on the same machine
Not sure if relevent, but I’m a developer and have never used power-shell before (nor has it been used on this machine before)… so my only guess is there is some sort of pre-requisite that I am supposed to have run or know about?
EDIT:
VERBOSE OUTPUT
PS E:\Backups\Script> Backup-SPFarm -Directory E:\Backups -BackupMethod Full -Verbose
VERBOSE: Leaving BeginProcessing Method of Backup-SPFarm.
VERBOSE: Performing operation "Backup-SPFarm" on Target "SHAREPOINTSERV".
Backup-SPFarm : Object reference not set to an instance of an object.
At line:1 char:14
+ Backup-SPFarm <<<< -Directory E:\Backups -BackupMethod Full -Verbose
+ CategoryInfo : InvalidData: (Microsoft.Share...mdletBackupFarm:SPCmdletBackupFarm) [Backup-SPFarm], NullReferenceException
+ FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletBackupFarm
VERBOSE: Leaving ProcessRecord Method of Backup-SPFarm.
VERBOSE: Leaving EndProcessing Method of Backup-SPFarm.
Unfortunately, as I suspected this was something simple, but took a long time to work out (thanks to Microsoft’s amazingly useful error message :p )
I had opened Sharepoint Management Shell before, but as a different user, which meant I did see a vital message that would point me in the right direction…
When I set up the server, there was no need to log into SQL Server other than to set up the service accounts (I think I logged in as my user, not the enterprise admin) and the enterprise admin didn’t have any SQL Server permissions.
I suspected the line
Add-PsSnapin Microsoft.SharePoint.Powershellhadn’t worked properly, even though it said it did.As I was trying to create a powershell script through the powershell editor I never opened Sharepoint Management Shell as the admin user I had logged in as.
Once I had seen the message in Sharepoint Management Shell, I googled it, and problem solved.
It would have been nice of Microsoft to display this instead of the object reference message!