Technical Article

Display SQL services information

,

By using the Windows Management Instrumentation command (WMIC) we can find the details.WMIC is probably one of the most powerful administrators tool and can be used for getting information and shutting down services, monitoring process, if you need to find the service Account information for SQL Server services on all SQL Servers remotely? Try this below steps to get the results in one single line command:

Please find the below process to get the service account details for the given list of servers.

Step1. Copy the below code into notepad and save it as SQL.bat in C:> Drive
Step2. Run command prompt as C:\SQL.bat Houston1 Houston2 Houston3 >C:\Output.xls
Note: Please give the machine name is physical Box name Houston1 Houston2 Houston3.............your list of physical server names

Code
@echo off
@if "%1"=="?" goto Syntax
@if "%1"=="" goto Local
rem ********************************************************
rem Description: Display SQL servicess information
rem **********************************************************

:Loop
if {%1}=={} goto :EXIT
@echo ************************
@echo Machine: %1
@echo ************************
wmic /node:%1 service WHERE "(Name Like 'MSSQL%%' OR Name Like 'SQLAgent%%' OR Name Like 'SQLServer%%' OR Name = 'MSDTC') And Name <> 'MSSQLServerADHelper'" get DisplayName, Name, startname
SHIFT /1
goto Loop

:Local
@echo ******************************************
@echo *** Machine: %COMPUTERNAME%
@echo ************************************************
wmic service WHERE "(Name Like 'MSSQL%%' OR Name Like 'SQLAgent%%' OR Name Like 'SQLServer%%' OR Name = 'MSDTC') And Name <> 'MSSQLServerADHelper'" get DisplayName, Name, startname
goto :EXIT

:Syntax
@echo Syntax: sql [Houston1 Houston2 Houston3 ....]
goto :EXIT

:EXIT

@echo off@if "%1"=="?" goto Syntax@if "%1"=="" goto Localrem **********************************rem Script svc.batrem Creation Date: 5/14/2007rem Author: Chad Miller ganesh.pittala@gmail.comrem ***********************************rem Description: Display SQL services informationrem ***********************************
:Loopif {%1}=={} goto :EXIT@echo ************************@echo *** Machine: %1@echo ************************wmic /node:%1 service WHERE "(Name Like 'MSSQL%%' OR Name Like 'SQLAgent%%' OR Name Like 'SQLServer%%' OR Name = 'MSDTC') And Name <> 'MSSQLServerADHelper'" get DisplayName, Name, startname 2>&1SHIFT /1goto Loop
:Local@echo ************************@echo *** Machine: %COMPUTERNAME%@echo ************************wmic service WHERE "(Name Like 'MSSQL%%' OR Name Like 'SQLAgent%%' OR Name Like 'SQLServer%%' OR Name = 'MSDTC') And Name <> 'MSSQLServerADHelper'" get DisplayName, Name, startname 2>&1goto :EXIT
:Syntax@echo Syntax: sql [HOU150NT3V248 HOU150NT3V246 HOU150NTAH3S17 ...]goto :EXIT
:EXIT

Rate

2.5 (2)

You rated this post out of 5. Change rating

Share

Share

Rate

2.5 (2)

You rated this post out of 5. Change rating