Saturday, May 23, 2026

SQL 2025 master class LAB 08 best practices assessment

 

Powershell as admin

 Install-PackageProvider -Name NuGet -Force

Install-Module -Name SqlServer -force -allowclobber

Import-Module -Name SqlServer -force  

$srv = New-Object Microsoft.SqlServer.Management.Smo.Server("windows")

$srv.databases 

Get-SqlAssessmentItem $srv

Invoke-SqlAssessment $srv| Out-File -FilePath "C:\SQL_BPA_Report.html"

if needed import-module sqlps

get-psprovider

cd sqlserver:\

dir

cd sql

cd windows

dir

-- 1. Allow the use of advanced configuration options
EXEC sp_configure 'show advanced options', 1;
RECONFIGURE;

-- 2. Enable the xp_cmdshell feature
EXEC sp_configure 'xp_cmdshell', 1;
RECONFIGURE;

-- 3. (Optional) Hide advanced options again
EXEC sp_configure 'show advanced options', 0;
RECONFIGURE;

--with thanks and acknowledgement to https://www.mssqltips.com/sqlservertip/7435/check-sql-server-best-practice-settings-invoke-sqlassessment/