SQL SERVER – Script to find SQL Startup Account using WMIC

Friends are your lifeline that keep your life interesting. I have various friends’ circles that range from family, acquaintances, work and the most exciting circle is the technical circles. Most of the times the tech circles is what fuels most of the post that lands up here. I was talking to one of my friend and he gave a passing statement without much info. It was in my mind for a long time to research, but am I glad I figured out. I learned new way to find details about SQL Server startup account – using WMIC. I did some more research with this and sharing it with my blog readers.

What is WMIC? It stands for Windows Management Instrumentation Command. In simple words, WMIC is a utility which allows us to interact with WMI from a WMI-aware command-line shell.  All WMI objects and their properties, including their methods, are accessible through the shell, which makes WMIC a super strong console.

WMIC has a parameter for Service application management. To get help we can use /? as shown below:

SQL SERVER - Script to find SQL Startup Account using WMIC wmic-01

We can use where clause and get method to get details about services related to SQL Server. Here is the naming which is consistent since old days:

SQL ComponentDisplay NameService Name
SQL Server – Default InstanceSQL Server (MSSQLSERVER)MSSQLServer
SQL Server – Named InstanceSQL Server (NameOfInstance)MSSQL$NameOfInstance
SQL Server Agent – Default InstanceSQL Server Agent (MSSQLSERVER)SQLSERVERAGENT
SQL Server Agent – Named InstanceSQL Server Agent (NameOfInstance)SQLAgentNameOfInstance
SQL Server BrowserSQL Server BrowserSQLBrowser
SQL Server Full text – Default InstanceSQL Full-text Filter Daemon Launcher (MSSQLSERVER)MSSQLFDLauncher
SQL Server Full text – Named InstanceSQL Full-text Filter Daemon Launcher (NameOfInstance)MSSQLFDLauncher$SQL2014

You can add more to list for Reporting Services, Analysis Services etc.

Here is the WMI query which can list services using like operator. If you can familiar with T-SQL then you would know that % is operator.

wmic service where “name Like ‘%MSSQL%’ or name like ‘%SQL%Agent%'” get Name , StartName

and here is the output

SQL SERVER - Script to find SQL Startup Account using WMIC wmic-02

Did you find it interesting? Do let me know what you find in your environments? The learning will never stop here though.

Reference: Pinal Dave (https://blog.sqlauthority.com)

Previous Post
SQL SERVER – Using MaxTransferSize parameter with SQL Server Backups
Next Post
SQL SERVER – Quiz on knowing DATEPART and DATENAME Behaviors

Related Posts

No results found.

Leave a Reply