All posts filed under: SQL

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: