14,162 total views, 1 views today
In this provisioning SharePoint Search Service Application article, we will learn about how to re-provision the SharePoint search service application using the PowerShell script. Many times, we may be in need that needs to re-provision the search service application or any other service applications that got corrupted or not working anymore due to some technical reasons. For example, if you don’t find the “Indexing Schedule Manager on <Server Name>” timer job on your farm, you must re-provision the search service application.
Step1: Provisioning SharePoint Search Service Application
Using the below PowerShell command get all service applications from the farm:
Get-SPServiceApplication
The command will list out all service applications with their name and ID from the SharePoint farm.
Step 2:
Now, get the specific service application by the ID parameter or name like below:
####The below script is used to re-provision the SharePoint search service application. cls $PSshell = Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorVariable err -ErrorAction SilentlyContinue if($PSshell -eq $null) { Add-PSSnapin "Microsoft.SharePoint.PowerShell" } $fileName = "ReProvisionSharePointSSA_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 re-provison the search service Application in SharePoint on-premise################################## #Get-SPServiceApplication -Identity GUID ID, example shown below: Try { $ssa=Get-SPServiceApplication -Identity e2c2be70-6382-4ce7-8a55-ae7dadff5786 #or #Get-SPServiceApplication -Name service application name, example shown below: $ssa=Get-SPServiceApplication -Name "Search Service Application" #Now make sure that the $ssa variable returning the correct object by typing the $ssa in the next line command. #Once you see the that $ssa is returning the correct search service application details, run the below provision method. $ssa.Provision() } catch { $ErrorMessage = $_.Exception.Message +"in re-provisioning the SSA in SharePoint on-premise!:" Write-Host $ErrorMessage -BackgroundColor Red Write-Log $ErrorMessage } ##############The below code is used to re-provison the search service Application in SharePoint on-premise - ends here##################################
Note:
- In the above example, the way we have re-provisioned the SharePoint search service application, we can re-provision any service application from the SharePoint farm, just we need to pass the correct service application name or GUID in the Get-SPServiceApplication command.
- Until it is needed (or corrupted), do not re-provision any service application.
- First, run the above script or command in the test server before running it in the prod server.
Summary: provisioning SharePoint Search Service Application
Thus, in this article, we have learned about how to re-provision the SharePoint search service application using PowerShell script or how to re-provision any SharePoint service applications using the PowerShell script.
See Also: provisioning SharePoint Search Service Application
You may also like the following SharePoint PowerShell tutorials:
- [Fixed]: Start SharePoint Central Administration service using PowerShell
- [Fixed]: Restore the timer service in SharePoint Server using PowerShell script
- [Fixed]: Remove-MsolServicePrincipalCredential : Access Denied. You do not have permissions to call this cmdlet.
- [Fixed]: The term ‘Get-MsolServicePrincipal’ is not recognized as the name of a cmdlet, function, script file,
- [Verified]: Find all InfoPath forms in SharePoint using PowerShell
- [Verified]: Remove recycle bin items in SharePoint using PowerShell
- [Verified]: Cancel SharePoint workflows using PowerShell
- SharePoint Online: Remove custom app using PnP PowerShell
- Office 365: How to create content type in SharePoint Online using PowerShell?
- Office 365: How to create document library in SharePoint Online using PowerShell?
- Export SharePoint user information list to CSV(Excel) file using PowerShell
- How to fix “The term ‘Get-MsolUser’ is not recognized as the name of a cmdlet”
- How to fix the “The term ‘Get-SPWeb’ is not recognized as the name of a cmdlet, function” PowerShell error
- How to hide quick launch menu in SharePoint online using PnP PowerShell
- Edit user Permission is greyed Out SharePoint Online
- Get workflow inventory from SharePoint online using PowerShell CSOM
- Create a modern team site using PnP PowerShell in SharePoint
- In 2 steps convert a classic SharePoint page to modern using PnP
- SharePoint Online: Delete All Files from document library for the given date – PowerShell CSOM
- Create SharePoint online list using PnP provisioning template
- SharePoint Automation: PowerShell script to get remote server information
- Office 365: Retrieve hub sites and associated sites using PnP Powershell
- SharePoint Online Automation – O365 – Upload files to document library using PowerShell CSOM
- SharePoint Online Automation – O365 – Create multiple items in a list using PowerShell CSOM
- SharePoint Online Automation – O365 – Update document library metadata using PowerShell CSOM
- New-SPEnterpriseSearchServiceApplication
Buy the premium version of SharePoint Online & Office 365 administration eBook from here: