[Fixed]: Start SharePoint Central Administration service using PowerShell

No comments

 2,835 total views,  6 views today

As we know SharePoint Central administration site is the heart of everything in SharePoint on-premise when it comes to managing the SharePoint farm, this site generally gets hosted in the application server and it runs by the “Central Administration ” service. This can be managed through the SharePoint central administration site “Central Administration -> Manage Services on the server” navigation.  But, remember when your central administration site itself does not open – it throws the “Internet Explorer cannot display the webpage” error which means due to some reason or accidentally  “Central Administration” has been stopped in the SharePoint farm.

In this article, we will learn about how to start the SharePoint central administration service using the PowerShell script.

####The below script is used to start the SharePoint central administration service.

cls

$PSshell = Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorVariable err -ErrorAction SilentlyContinue 
if($PSshell -eq $null)
{
Add-PSSnapin "Microsoft.SharePoint.PowerShell"
}

$fileName = "StartCentralAdministrationService_using_PowerShell"

#'yyyyMMddhhmm yyyyMMdd
$enddate = (Get-Date).tostring("yyyyMMddhhmmss")
#$filename = $enddate + '_VMReport.doc'
$logFileName = $fileName +"_"+ $enddate+"_Log.txt"
$invocation = (Get-Variable MyInvocation).Value
$directoryPath = Split-Path $invocation.MyCommand.Path

$directoryPathForLog=$directoryPath+"\"+"LogFiles"
if(!(Test-Path -path $directoryPathForLog))
{
New-Item -ItemType directory -Path $directoryPathForLog
#Write-Host "Please Provide Proper Log Path" -ForegroundColor Red
}
#$logPath = $directoryPath + "\" + $logFileName

$logPath = $directoryPathForLog + "\" + $logFileName

$isLogFileCreated = $False

function Write-Log([string]$logMsg)
{
if(!$isLogFileCreated){
Write-Host "Creating Log File..."
if(!(Test-Path -path $directoryPath))
{
Write-Host "Please Provide Proper Log Path" -ForegroundColor Red
}
else
{
$script:isLogFileCreated = $True
Write-Host "Log File ($logFileName) Created..."
[string]$logMessage = [System.String]::Format("[$(Get-Date)] - {0}", $logMsg)
Add-Content -Path $logPath -Value $logMessage
}
}
else
{
[string]$logMessage = [System.String]::Format("[$(Get-Date)] - {0}", $logMsg)
Add-Content -Path $logPath -Value $logMessage
}
}

##############The below code is used to start the 'Central Administration' service in SharePoint on-premise##################################

Try
{
#Pass the 'Central Administration' as the service name, however, you can pass any service name which you want to start.
Get-SPServiceInstance | Where-Object {$_.TypeName –eq 'Central Administration'} | Start-SPServiceInstance
}
Catch
{

$ErrorMessage = $_.Exception.Message +"in starting the central administration service in SharePoint on-premise!:" 
Write-Host $ErrorMessage -BackgroundColor Red
Write-Log $ErrorMessage

}

###The below code is used to start the 'Central Administration' service in SharePoint on-premise - ends here####

Once you run the above script, the central administration site should open, however, if you still face the same issue, it might be the reason that the timer job service is not running on the server, so start the SharePoint timer job service in the application server.

Then run the below command:


Get-SPServiceInstance | Where-Object {$_.TypeName –eq 'Central Administration'}

The status before we run the command will be in the “Disabled” state, then the status will be changed to “Provisioning” and finally to “Online“.

Now, if you try to open the SharePoint central administration site in the browser it should open.

Summary:

Thus, in this article, we have learned about how to start the central administration service in SharePoint using the PowerShell script.

See Also:

You may also like the following SharePoint PowerShell tutorials:

Buy the premium version of SharePoint Online & Office 365 administration eBook from here:

Buy SharePoint Online & Office 365 Administration eBook