Posted On September 1, 2020

PowerShell: Graceful Shutdown of MS SQL Server

kimconnect 0 comments
blog.KimConnect.com >> Database >> PowerShell: Graceful Shutdown of MS SQL Server
import-module sqlps
CD SQLSERVER:\SQL\$env:computername
$sql = (get-item .).ManagedComputer
# This command stops MSSQL$instanceName, SQLSERVERAGENT, SQLAGENT$instanceName, and SQLBROWSER
$sql.Services|%{$_.Stop()}

# Alternative method: less thorough
stop-service mssqlserver
# Sample output:
PS SQLSERVER:\SQL\SQL05> $sql.Services.Name
MSSQLFDLauncher
MSSQLSERVER
SQLBrowser
SQLSERVERAGENT

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post

ODBC Driver 32-bit & 64-bit

The 32-bit version: Run: odbcad32.exe > check the list of installed 32-bit drivers as illustrated…

Check Servers NSLookup of a Listener to Match Active Node IP

$servers="SQL01","SQL02","SQL03","SQL04" $listener="halistener01" $activeNode="10.10.10.5" # Dynamic Credential method 1 $who = whoami if ($who.Substring($who.length-2, 2)="-admin"){$username=$who;} else…

MySQL on Localhost

Modern versions of MySQL is memory intensive; thus, it is a pre-requisite that an adequate…