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

Microsoft SQL: Shrink vs Truncate

Shrink The shrink command is to reduce the physical log file size of a database.…

Microsoft SQL Server Replication Setup Error Number MSSQL_REPL2110 and Resolution

Symptom: The distribution agent failed to create temporary files in 'C:\Program Files\Microsoft SQL Server\130\COM' directory…

SQL: DELETE FROM Statement

DELETE FROM `Profiles` WHERE Picture = '0'--------------------------------------------------Change password to "sexcenter"UPDATE `Profiles`SET Password = '5863294bde549649adab89940c3e09ea'WHERE Password…