Streamline SQL Server Service Checks with PowerShell

In this post, we will present a PowerShell script designed to check the status of SQL Server services on your machine or across your network. Ensuring that your SQL Server services are running smoothly is vital for maintaining database availability and performance. This script allows administrators to quickly verify the status of each SQL Server service, making it easier to troubleshoot potential issues.
Here is the PowerShell script for checking SQL Server service status:

# Define the SQL Server services to check
$services = @("MSSQLSERVER", "SQLAgent$SQLEXPRESS")  # Add your SQL Server instance names as needed
# Check the status of each service
foreach ($service in $services) {
    $serviceStatus = Get-Service -Name $service -ErrorAction SilentlyContinue
    if ($serviceStatus) {
        Write-Host "$($serviceStatus.DisplayName) is currently $($serviceStatus.Status)." -ForegroundColor Green
    } else {
        Write-Host "Service $service is not found." -ForegroundColor Red
    }
}