1

I have Sharepoint 2013 and Powershell deployment.

I execute muy ps1 script in SPS01 machine. Farm servers are SPS01, SPS02, SPS03, SPS04. User for deploy is UserInstallerMoss , it's Farm Administrator and only local Administrator in SPS01, not in others servers.

I call this function:

function RestartTimerFarm
{
    Write-Host -f Green Restarting OWSTIMER instances on Farm
    $farm = Get-SPFarm
    $farm.TimerService.Instances | foreach {$_.Stop();$_.Start();}
} 

I get this error when its call to Stop method:

This operation uses the SharePoint Administration service (spadminV4), which could not be contacted. If the service is stopped or disabled, start it and try the operation again.)

Now, I set UserInstallerMoss as local Administrator in SPS01, SPS02, SPS03, SPS04.

I get this error:

This operation uses the SharePoint Administration service (spadminV4), which could not be contacted. If the service is stopped or disabled, start it and try the operation again.)

But if I execute WMI and Get-SPServer cmdlet all is OK

$servers=Get-SPServer | where {$_.role -ne "Invalid" }
        foreach ($server in $servers)
        {
            $serverName = $server.Name
            WriteTrace("Server in Farm... " + $serverName)

            CheckRemoteServiceStatus -Machine $serverName -Name "SPAdminV4" -Status "Running"

            WriteTrace("Restarting SPTimerV4 service in server... " + $serverName)

            $result = (Get-WmiObject -computer $serverName Win32_Service -Filter "Name='SPTimerV4'").InvokeMethod("StopService",$null)
            Start-Sleep -seconds 2
            $result = (Get-WmiObject -computer $serverName Win32_Service -Filter "Name='SPTimerV4'").InvokeMethod("StartService",$null)

            WriteTrace("SPTimerV4 service restarted in server " + $serverName)
        }
  • Are you running the commands on the server which runs the Central Administration? This error message could appear if commands are executed elsewhere. – moe Aug 6 '14 at 7:12
  • From my findings the $farm.TimerService.Instances doesn't implement start() or stop(), so this shouldn't work at all. Could you please explain first what you are trying to achieve with your script? – user32207 Aug 6 '14 at 8:48
  • I want restart Timer Service (SPtimerv4) in ALL servers in FARM. About Stop-Start : serverfault.com/a/556058 – Kiquenet Aug 6 '14 at 11:12
1

Open sharepoint management shell as administrator then execute the command , it is working for me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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