Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Got a service call yesterday that the backup hasn't been done for three months. Looking at the task scheduler history, there where no errors. So I run the PowerShell script myself, and got an exeption that PSSnapin hasn't been loaded. I added the familiar PSSnapin line, but still got the same exception.

We decided to restart the server, and after that the script ran fine agen without errors. But having to restart the server seems wrong. Is there a service on the server i can restart instead? If so, what's the name of that service?

The Script

Backup-SPFarm -Directory E:\Backup -BackupMethod full

The Problem (edited)

The problem that I face is that the Microsoft.SharePoint.Powershell didn't load at all. And that's the real problem. No matter which checks I did or continue silently (as suggested by Falak). It did not load. My thought is that there is a service that handles the .NET SharePoint.dll - which where inaccessible. I want to restart that service without restarting the server - if possible. Is there a service that controls PSSnapin Microsoft.SharePoint.Powershell?

share|improve this question
    
Sounds weird. You're talking about "the PowerShell script" - maybe you want to share parts of it? When you always create a new PS session and initialize the SharePoint Snapin in that session, you should be fine. Maybe you're keeping the session open for too long or something like that? –  Dennis G Feb 9 '13 at 13:26
    
Not really, I've added the script - but there's nothing special to it. –  Benny Skogberg Feb 9 '13 at 13:41

1 Answer 1

up vote 3 down vote accepted

Create a new task (see the image below). Since we are going to run the script using the standard Windows PowerShell console application so make sure that snap-in is already loaded.

$snapin = Get-PSSnapin | Where-Object {$_.Name -eq 'Microsoft.SharePoint.Powershell'} 
if ($snapin -eq $null) 
{    
    Write-Host "Loading SharePoint Powershell Snapin"    
    Add-PSSnapin "Microsoft.SharePoint.Powershell"  -EA SilentlyContinue
}
Backup-SPFarm -Directory E:\Backup -BackupMethod full

enter image description here

Update and try to register the SharePoint PowerShell dll manually

Open PowerShell cmd using admin and Go to: C:\Windows\Microsoft.NET\Framework64\v2.0.50727 and run the following command:

.\InstallUtil.exe /LogToConsole=true C:\Windows\assembly\GAC_MSIL\Microsoft.SharePoint.PowerShell\14.0.0.0__71e9bce111e9429c\Microsoft.SharePoint.Powershell.dll

You should be able to get the

The Commit phase completed successfully.

The transacted install has completed.

Happy SharePointing!

share|improve this answer
1  
Great, now let's delete the comments now! –  Falak Mahmood Feb 11 '13 at 15:57

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.