Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

find the status of SQL Services on multiple servers Expand / Collapse
Author
Message
Posted Thursday, February 21, 2013 11:07 PM


SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Thursday, April 10, 2014 11:09 PM
Points: 106, Visits: 438
I have a scenario where our DBAs and Server team planned for Maintenance, tonight.
We have more than 800 servers that are to be rebooted.
Is there any way, I can check the status of SQL Server and Agent Services, 'running', 'stopped', 'disabled', 'manual', 'if clustered', 'time started' on all multiple servers at a time ?

I would like to have a script towards it, if I can provide a servers list into text and then the output pumped to text or excel file.

Please help and thanks in advance.


Cheers,
- Win
"Dont Judge a Book by its Cover"
Post #1422885
Posted Friday, February 22, 2013 2:33 AM


SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Thursday, April 10, 2014 11:09 PM
Points: 106, Visits: 438
Found something, but only for one and it is also not accurate.. Any help is appreciated.


$servers=get-content "D:\instances.txt"
foreach($server in $servers)
{ get-wmiobject win32_service -computername $server |
select name,state |
where {
($_.name -like "SQLAGENT*" -or $_.name -like "SQL*AGENT" ) `
-and $_.state -match "Stopped"} | Out-String

}


Cheers,
- Win
"Dont Judge a Book by its Cover"
Post #1422931
Posted Saturday, February 23, 2013 1:56 AM


SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Thursday, April 10, 2014 11:09 PM
Points: 106, Visits: 438
any help is appreciated..

the below script gives report to only one machine twice when it is ran through VM.
List of servers are not getting used for checking.

why script not trying next server names in the list other than local instance.
it results for local machine only. I would like to pull details of
1. SQL Server & SQL Server Agent services, started and stopped.
2. If stopped, start them automatically.
3. again check for status.

I am trying for 3 steps handy and verified after maintenance..

----------------------------------------------------------------------------------------------------------------------------
#create final results to export
$results = @()
# Defining output format for each column.
$fmtName =@{label="Service Name" ;alignment="left" ;width=30 ;Expression={$_.Name};};
$fmtMode =@{label="Start Mode" ;alignment="left" ;width=10 ;Expression={$_.StartMode};};
$fmtState =@{label="State" ;alignment="left" ;width=10 ;Expression={$_.State};};
$fmtStatus =@{label="Status" ;alignment="left" ;width=10 ;Expression={$_.Status};};
$fmtMsg =@{label="Message" ;alignment="left" ;width=50 ; `
Expression={ if (($_.StartMode -eq "Auto") -and ($_.State -ne "Running") ) {"Alarm: Stopped"} };};

foreach ($svr in Get-Content "C:\SQLinstances.txt")
{
$srvc = Get-WmiObject `
-query "SELECT *
FROM win32_service
WHERE name LIKE '%SQL%'
OR name LIKE '%MSOLAP%'
OR name LIKE '%ReportServer%'
OR name LIKE '%MSDtsServer%'" `
-computername $server `
| Sort-Object -property name;

Write-Output ("Server: {0}" -f $server);
Write-Output $srvc | Format-Table $fmtName, $fmtMode, $fmtState, $fmtStatus, $fmtMsg;
}

$results | Export-Csv -Path C:\results.csv


Cheers,
- Win
"Dont Judge a Book by its Cover"
Post #1423327
Posted Saturday, February 23, 2013 10:17 AM


SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Thursday, April 10, 2014 11:09 PM
Points: 106, Visits: 438
Appreciate if anyone can help.

---- ONe more add on.
I have SQL 2000, 2005, 2008, R2 & 2012 in place, of 800+ servers.


Cheers,
- Win
"Dont Judge a Book by its Cover"
Post #1423359
Posted Sunday, February 24, 2013 7:43 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Tuesday, January 21, 2014 8:29 AM
Points: 244, Visits: 476
Hi,

have you kept the firewall settings in mind. Have you allowed the remote powershell ports?
http://blogs.technet.com/b/christwe/archive/2012/06/20/what-port-does-powershell-remoting-use.aspx

Another possibility to check the running server:
You can use the Registered Servers feature of the SSMS. Generate a serverlist to import and start a new query. All server without connection would be listed in the messages window.


Kind regards,

Patrick Fiedler
Consultant

Fiedler SQL Consulting

www.fiedler-sql-consulting.de
Post #1423418
Posted Tuesday, February 26, 2013 2:56 AM


SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Thursday, April 10, 2014 11:09 PM
Points: 106, Visits: 438
yes we are using Powershell already for all the machines.
But I am to trying to get this done by SQL Queries.

Is there any way to add all the servers to "Central Management Servers".

One by one registering will take long time for me to register lot number of SQL servers.




Cheers,
- Win
"Dont Judge a Book by its Cover"
Post #1423954
Posted Tuesday, February 26, 2013 2:26 PM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Tuesday, January 21, 2014 8:29 AM
Points: 244, Visits: 476
Hi,

With registered Servers it could be ok. Add two Server to the registered Server, Export it and try to generate the XML with select on the Server list. And Then try Import it.


Kind regards,

Patrick Fiedler
Consultant

Fiedler SQL Consulting

www.fiedler-sql-consulting.de
Post #1424248
Posted Wednesday, February 27, 2013 12:16 AM


SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Thursday, April 10, 2014 11:09 PM
Points: 106, Visits: 438
Thanks Patrick for your time.

Adding 800+ servers to "Central Management Servers" is a big problem and in manual.
Any automation for this to register.


Cheers,
- Win
"Dont Judge a Book by its Cover"
Post #1424358
Posted Wednesday, February 27, 2013 5:08 PM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Yesterday @ 10:21 PM
Points: 35,951, Visits: 30,235
Here'a a couple of what sounds like a decent tool I found in 10 minutes using my assistant DBA, Google.

I like this first one the most because I can call Powershell from xp_CmdShell (captures the result set directly) or just run Powershell separately and pipe the output to an importable file.

http://www.mssqltips.com/sqlservertip/2013/find-sql-server-instances-across-your-network-using-windows-powershell/

Here's another that goes above and beyond.

http://www.straightpathsql.com/archives/2009/02/what-sql-instances-are-installed-on-my-network/
http://www.microsoft.com/en-us/download/details.aspx?id=7826

MAP (Microsoft Assessment and Planning Toolkit) (from the links above) supposedly makes a spreadsheet and a word document with all the goodies you might care to lookup.



--Jeff Moden
"RBAR is pronounced "ree-bar" and is a "Modenism" for "Row-By-Agonizing-Row".

First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."

"Change is inevitable. Change for the better is not." -- 04 August 2013
(play on words) "Just because you CAN do something in T-SQL, doesn't mean you SHOULDN'T." --22 Aug 2013

Helpful Links:
How to post code problems
How to post performance problems
Post #1424815
Posted Wednesday, February 27, 2013 5:33 PM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Yesterday @ 8:11 PM
Points: 20,455, Visits: 14,075
This should do what you need. If it doesn't work, I wonder if there may be some firewall policy or server security blocking you.

gwmi win32_service -comp (gc servers.txt) |

select __server,name,startmode,state,status




Jason AKA CirqueDeSQLeil
I have given a name to my pain...
MCM SQL Server


SQL RNNR

Posting Performance Based Questions - Gail Shaw
Posting Data Etiquette - Jeff Moden
Hidden RBAR - Jeff Moden
VLFs and the Tran Log - Kimberly Tripp
Post #1424824
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse