Catch: this lists any service that has “SQL” in it, so can potentially list MySQL services too
ListAll SQL services
#list stopped SQL Server services $computername = "APHRODITE" Get-WmiObject win32_service -computername $computername | select name, state | where { ($_.name -like "SQLAGENT*" -or $_.name -like "*SQL*") ` }
Another way to do this:
#note ComputerManagement works on SQL Server 2005 #on SQL Server 2008 this has to be ComputerManagement10 Get-WmiObject ` -namespace rootMicrosoftSqlServerComputerManagement ` -class SqlService | Select-Object ServiceName, DisplayName, SQLServiceType, State
List Stopped SQL services
#list stopped SQL Server services $computername = "APHRODITE" Get-WmiObject win32_service -computername $computername | select name, state | where { ($_.name -like "SQLAGENT*" -or $_.Name -like "*SQL*") ` -and $_.State -match "Stopped" }
List Running SQL services
#list stopped SQL Server services $computername = "APHRODITE" Get-WmiObject win32_service -computername $computername | select name, state | where { ($_.name -like "SQLAGENT*" -or $_.Name -like "*SQL*") ` -and $_.State -match "Stopped" }SQL Server PowerShell : How to List SQL Server Services using PowerShell,
Filed under:
DBA Toolbox / T-SQL Scripts, Powershell
Running services seems to be a copy and paste from stopped services…
Thanks for the post.
By the other hand, good blog.
How to List SQL Server Services using PowerShell – how can we get the report of SQL Server & Agent services running for Multiple servers.
I would like to have it into Excel.
hi. can i ask for a script if i’d like to only check one server?