Check SQL Server/agent status without login to the server/box itself?

  • Is it possible to check SQL Server/agent status without login to the server/box itself?

    Need to check whether it is running/stopped, and it is set to auto-start or manual. The information we usually see from services applet or SQL Server Service Manager/Configuration Manager while on the server.

  • Here is a vbscript that will give you a list of all services and the state. Save the file as a .vbs and run it. You can modify it to meet your needs, but it may be a starting point for you.

    strComputer = "."

    strServices = ""

    Set objWMIService = GetObject("winmgmts:" _

    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

    Set colRunningServices = objWMIService.ExecQuery _

    ("Select * from Win32_Service WHERE DisplayName Like '%sql%'")

    For Each objService in colRunningServices

    strServices = strServices + objService.DisplayName & VbTab & objService.State & vbcr

    Next

    Wscript.Echo strServices

  • Thank you Ken. That is a good starting point.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply