Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
SQL Server 2008
»
SQL Server 2008 Administration
»
find the status of SQL Services on multiple...
find the status of SQL Services on multiple servers
Rate Topic
Display Mode
Topic Options
Author
Message
- Win
- Win
Posted Thursday, February 21, 2013 11:07 PM
SSC Journeyman
Group: General Forum Members
Last Login: Thursday, May 09, 2013 12:06 AM
Points: 86,
Visits: 318
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
- Win
- Win
Posted Friday, February 22, 2013 2:33 AM
SSC Journeyman
Group: General Forum Members
Last Login: Thursday, May 09, 2013 12:06 AM
Points: 86,
Visits: 318
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
- Win
- Win
Posted Saturday, February 23, 2013 1:56 AM
SSC Journeyman
Group: General Forum Members
Last Login: Thursday, May 09, 2013 12:06 AM
Points: 86,
Visits: 318
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
- Win
- Win
Posted Saturday, February 23, 2013 10:17 AM
SSC Journeyman
Group: General Forum Members
Last Login: Thursday, May 09, 2013 12:06 AM
Points: 86,
Visits: 318
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
Patrick_Fiedler
Patrick_Fiedler
Posted Sunday, February 24, 2013 7:43 AM
SSC Veteran
Group: General Forum Members
Last Login: Tuesday, May 21, 2013 10:46 AM
Points: 244,
Visits: 470
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
- Win
- Win
Posted Tuesday, February 26, 2013 2:56 AM
SSC Journeyman
Group: General Forum Members
Last Login: Thursday, May 09, 2013 12:06 AM
Points: 86,
Visits: 318
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
Patrick_Fiedler
Patrick_Fiedler
Posted Tuesday, February 26, 2013 2:26 PM
SSC Veteran
Group: General Forum Members
Last Login: Tuesday, May 21, 2013 10:46 AM
Points: 244,
Visits: 470
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
- Win
- Win
Posted Wednesday, February 27, 2013 12:16 AM
SSC Journeyman
Group: General Forum Members
Last Login: Thursday, May 09, 2013 12:06 AM
Points: 86,
Visits: 318
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
Jeff Moden
Jeff Moden
Posted Wednesday, February 27, 2013 5:08 PM
SSC-Dedicated
Group: General Forum Members
Last Login: Today @ 4:51 PM
Points: 32,923,
Visits: 26,811
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 "
R
ow-
B
y-
A
gonizing-
R
ow".
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."
For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
Post #1424815
SQLRNNR
SQLRNNR
Posted Wednesday, February 27, 2013 5:33 PM
SSCoach
Group: General Forum Members
Last Login: Today @ 10:25 AM
Points: 18,754,
Visits: 12,337
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 2008
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 »
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.