August 27, 2013 at 8:19 am
Hello everyone
Can anyone offer some advice on how I would capture SQL server services, i.e started etc for each SQL instance in a .txt file containing the servers I want to look at ?
One issue I have is that I need to use SQL authentication to connect to the boxes as they are across different domains.
Any tips or help greatly appreciated.
All I want is a list exported to excel , Server name , SQL Service status etc.
Many thanks for any advice.
August 28, 2013 at 6:23 am
A web search using the words "Services Powershell Status" leads to the following:
get-service -name "MSSQLServer" -Computername TargetServerName
Which returns
Status Name DisplayName
------ ---- -----------
Running MSSQLServer SQL Server (MSSQLSERVER)
For named instances, the format is MSSQLServer$instancename
August 28, 2013 at 7:10 am
schleep (8/28/2013)
get-service -name "MSSQLServer" -Computername TargetServerName
Which returns
Status Name DisplayName
------ ---- -----------
Running MSSQLServer SQL Server (MSSQLSERVER)
For named instances, the format is MSSQLServer$instancename
Thank you for your reply.
I get the error : This operation might require other privileges when I try to connect with SQL authentication in place.
It works fine when I try on my local machine for 1 instance where I know my AD permission has the required privs.
I need to connect with SQL authentication as I am trying to go cross domains.
August 28, 2013 at 8:03 am
Some definitions appear to be in order:
machine = the physical / virtual server on which an instance of SQL Server is installed.
SQL Server = software that runs on a machine. There can be one or more instances of SQL Server installed on a machine.
For what you're trying to accomplish, you need permissions to
1) connect to the machines running the SQL Server services
2) view the status of services running on those machines.
If you don't have 1), it's all over. Even if you do have 1), you may not have 2): that will be up to your sysadmin.
At no point do you need to login to any SQL Server: this has nothing to do with SQL Authentication whatsoever. You can have an SQL Login and DB access on a SQL Server, but without the rights to connect to the machine running that SQL Server, well, you won't get in. Also, even if you are allowed to connect to the machine, if the SQL Server service is not started, your SQL Authentication will fail.
You'll need to use the Get-WmiObject instead, it allows you to pass credentials. You can look it up.
Get-WmiObject win32_service -comp "ServerName" | select __server,name,startmode,state,status
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply