Press "Enter" to skip to content

Category: Powershell

Building a SQL Server Estate Summary from Get-SqlSafe Reporting

Andreas Wolter digs into an environment and builds a report:

Have you ever needed to understand an unfamiliar SQL Server estate quickly? Perhaps you inherited an environment, started working with a new customer, or discovered that the existing server inventory is no longer trustworthy.

In the previous article, Running Get-SqlSafe at Scale Across a SQL Server Estate, I showed how to run Get-SqlSafe across a list of SQL Server instances.

Each report contains a System Overview section. I originally added this section to provide context for the security findings, but it also provides useful estate information such as the SQL Server version, build number, edition, and selected usage indicators.

Click through to see how.

Leave a Comment

Assessing SQL Server Security across an Estate

Andreas Wolter scales things up:

Get-SqlSafe is a free SQL Server security assessment that checks for common configuration, access-control, authentication, auditing and generates a detailed HTML report.

It has been publicly available for a couple of months and has already received several valuable additions based on user feedback, including console-only mode, Amazon RDS for SQL Server support, and per-database reports.

It has been encouraging to see Get-SqlSafe being used in real environments, including some very large ones.

In this post, I will show how to run the assessment against dozens or even hundreds of SQL Server instances using only a small additional PowerShell wrapper.

Click through for that wrapper.

Leave a Comment

Looping Databases on an Azure SQL Instance

Jess Pomfret has a script:

In the on-prem world, or when we’re working with SQL Servers on VMs, wherever they might live it was pretty easy with dbatools to run a query against all the databases, collect some info and collate it into one record set. This used to work with Azure SQL Instances too – but Azure auth, or cloud auth in general is hard and recently the Connect-DbaInstance command needed to change to make it more reliable.

So, this is a quick post to cover how we can still manage this.

Click through to see how.

Comments closed

Estimating Disk Space from .BAK Files

Garry Bargsley runs the numbers:

Today’s post comes from one of those real-world DBA situations where someone hands you a folder full of SQL Server backup files and asks what should be a simple question:

“How much disk space do we need to restore these?”

Simple question.

Not always a simple answer.

Click through for a script that calculates how much disk space you’d need to restore a given set of backups.

Comments closed

Invoke-Sqlcmd and Application vs Host Name

Greg Low notes a point of confusion:

I’ve always been a fan of having applications identify themselves in their connection strings. It makes tasks like tracing much easier. The tools supplied with SQL Server do a reasonable job of that as you can see above. But many other tools don’t do such a good job.

I was working at a site where they were using Powershell to execute commands for monitoring. I noticed that the Powershell commands did not set the Application Name in the connection string when using Invoke-Sqlcmd.

Read on to learn what Greg’s research discovered.

Comments closed

Fixing Blob Lease Issues on BACKUP TO URL

Greg Low fixes a problem:

Regardless of why you are using BACKUP TO URL, one of the problems that you are likely to run into at some point is the dreaded:

Msg 3271, Level 16, State 1, Line 60
A nonrecoverable I/O error occurred on file
“ https://somestorageaccount.blob.core.windows.net/backups/somedatabase.bak : “
Backup to URL received an exception from the remote endpoint. Exception Message: The remote server returned an error: (412) There is currently a lease on the blob and no lease ID was specified in the request…
Msg 3013, Level 16, State 1, Line 60
BACKUP DATABASE is terminating abnormally.

Click through to see when you might get this problem and how you can fix it.

Comments closed

WinGet and Path Not Updating

Justin Bird ran into some trouble:

Whilst I predominantly use MacOS, I do have to run a Windows VM for certain apps (cough Power BI cough). I ran into an issue recently when trying to installing apps on a vanilla Windows 10 build using Winget via the terminal in VS Code.

After installing the app, I found that the PATH environment variable was not updated, which meant I couldn’t run the app from the command line without specifying the full path.

Read on to learn what the issue was and how Justin was able to fix it.

Comments closed

PSBlitz 6.1.0 Released

Vlad Drumea has a new version of PSBlitz:

For anyone not familiar with PSBlitz: it’s a PowerShell-based tool that outputs SQL Server health and performance diagnostics data to either Excel or HTML, and saves execution plans and deadlock graphs as .sqlplan and .xdl files.

If you’re familiar with Oracle, this is pretty much my attempt of a SQL Server equivalent to Oracle’s AWR report.

Feel free to check out the blog post announcing PSBlitz 4 years ago, as well as the 3 year anniversary post.

Read on to see what Vlad has added.

Comments closed

Building a Multi-Instance Health Check with Powershell

Garry Bargsley puts it all together:

Over the past four weeks, you’ve built a real foundation. You know that single quotes are literal and double quotes expand variables. You know how to store and use data in variables – strings, integers, booleans, and hashtables. You know how to loop over a collection and do something useful to each item, including handling errors when a server doesn’t cooperate.

Now we put it all together. No new concepts this week, just everything you’ve learned working as a single, practical script that solves a real DBA problem. Think of it as your Jedi trials. The training is done. Time to use the Force.

Click through for the script. It’s fairly simple in terms of what it’s actually doing, but gives you a good idea of the types of things you can do.

Comments closed

Get-SqlSafe: A Baseline Assessment for SQL Server Security

Andreas Wolter has a new tool:

In my experience with SQL Server security assessments, many environments show typical patterns: excessive permissions, weak or missing auditing, legacy authentication exposure, risky configuration choices, and ownership or access-control drift accumulated over years.

Get-SqlSafe Community Edition was released to give teams and also consultants a practical first look at those high-level indicators. It is a free PowerShell-based assessment tool for Microsoft SQL Server, supporting all versions from SQL Server 2016-2025 that helps surface baseline issues before they turn into deeper security problems.

Click through for the link where to grab Get-SqlSafe Community Edition, as well as more information on how it works.

Comments closed