PoshUtils, PowerShell, Scripting, SQL
comment 1

PoshUtils: Get-DBSize – Get SQL Database space usage

Here is an improved version of the script I am using to get the database space usage details. This is one of the utility scripts I have been using and will be publishing soon as PoshUtils on Codeplex.

For this script to work, you need the SQL Management Object (SMO) assemblies. These assemblies are available on systems with SQL server installed or where SQL management tools are installed.

Here are some examples:

This gets the database space usage details for all databases on a SQL server named Server01.

The above example gets the space usage details for TestDB1 and TestDB2 on  a SQL Server named Server02.

This last example get the space usage details for TestDB1 and TestDB2 on the local SQL server. And, finally, you can avoid all parameters to get space usage for all databases on the local SQL Server.

Here is how the output looks:



Filed under: PoshUtils, PowerShell, Scripting, SQL


Ravikanth is a principal engineer and the lead architect for Microsoft and VMware virtualized and hybrid cloud solutions within the Infrastructure Solutions Group at Dell EMC. He is a multi-year recipient of Microsoft Most Valuable Professional (MVP) award in Windows PowerShell (CDM) and Microsoft Azure. Ravikanth is the author of Windows PowerShell Desired State Configuration Revealed (Apress) and leads Bangalore PowerShell and Bangalore IT Pro user groups. He can be seen speaking regularly at local user group events and conferences in India and abroad.