SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


find the status of SQL Services on multiple servers


find the status of SQL Services on multiple servers

Author
Message
- Win
- Win
Ten Centuries
Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)

Group: General Forum Members
Points: 1056 Visits: 707
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"
- Win
- Win
Ten Centuries
Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)

Group: General Forum Members
Points: 1056 Visits: 707
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"
- Win
- Win
Ten Centuries
Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)

Group: General Forum Members
Points: 1056 Visits: 707
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"
- Win
- Win
Ten Centuries
Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)

Group: General Forum Members
Points: 1056 Visits: 707
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"
Patrick_Fiedler
Patrick_Fiedler
SSChasing Mays
SSChasing Mays (612 reputation)SSChasing Mays (612 reputation)SSChasing Mays (612 reputation)SSChasing Mays (612 reputation)SSChasing Mays (612 reputation)SSChasing Mays (612 reputation)SSChasing Mays (612 reputation)SSChasing Mays (612 reputation)

Group: General Forum Members
Points: 612 Visits: 488
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

- Win
- Win
Ten Centuries
Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)

Group: General Forum Members
Points: 1056 Visits: 707
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"
Patrick_Fiedler
Patrick_Fiedler
SSChasing Mays
SSChasing Mays (612 reputation)SSChasing Mays (612 reputation)SSChasing Mays (612 reputation)SSChasing Mays (612 reputation)SSChasing Mays (612 reputation)SSChasing Mays (612 reputation)SSChasing Mays (612 reputation)SSChasing Mays (612 reputation)

Group: General Forum Members
Points: 612 Visits: 488
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

- Win
- Win
Ten Centuries
Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)

Group: General Forum Members
Points: 1056 Visits: 707
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"
Jeff Moden
Jeff Moden
SSC Guru
SSC Guru (340K reputation)SSC Guru (340K reputation)SSC Guru (340K reputation)SSC Guru (340K reputation)SSC Guru (340K reputation)SSC Guru (340K reputation)SSC Guru (340K reputation)SSC Guru (340K reputation)

Group: General Forum Members
Points: 340661 Visits: 42644
Here'a a couple of what sounds like a decent tool I found in 10 minutes using my assistant DBA, Google. :-P

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.
If you think its expensive to hire a professional to do the job, wait until you hire an amateur. -- Red Adair

Helpful Links:
How to post code problems
How to post performance problems
Forum FAQs
SQLRNNR
SQLRNNR
SSC Guru
SSC Guru (100K reputation)SSC Guru (100K reputation)SSC Guru (100K reputation)SSC Guru (100K reputation)SSC Guru (100K reputation)SSC Guru (100K reputation)SSC Guru (100K reputation)SSC Guru (100K reputation)

Group: General Forum Members
Points: 100250 Visits: 18616
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, MVP


SQL RNNR

Posting Performance Based Questions - Gail Shaw

Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search