Sharepoint Search Error/Search Service stuck at starting/Start or Stop a service using powershell

If ever you encounter a problem where search service is stuck at starting,or you recieve following message in event viewer related to search service, try steps given below:

The Execute method of job definition Microsoft.SharePoint.Search.Administration.SPSearchJobDefinition (ID ) threw an exception. More information is included below.
Retrieving the COM class factory for component with CLSID {} failed due to the following error: .
Event ID: 6398

First of all check if search service is started in services.msc

If still problem persists,
1) open windows powershell
2) Get Service InstanceID of search service application by entering following command:

​It will display all services with its ID

searchservice (1)

3) Copy ID of search service  and execute following command

Stop-SPServiceInstance -Identity <ID of search service>


4)Start search service using following command

Start-SPServiceInstance -Identity <ID of search service>