Using dbatools to check server disk space: Get-DbaDiskSpace

If you want to check how much free space you have on your Sql Server, you can just Remote Desktop in and check right? Yes, but I will show you an easier way using dbatools and a way to check multiple servers at once!

If you do not know what dbatools is, please read my previous posting about what it is, does and installation tips. DBATOOLS.IO….A DBA timesaver/luxury.

Ok, open up PowerShell and type in the following command to see what disk space you have available. The parameter for -ComputerName is the server that you want to check. In this example I am using Windows Authentication, so I do not have to pass in any credentials.

Get-DbaDiskSpace -ComputerName etlsqldb

This shows that I have two drives, the capacity, the amount free, and percentage free. Pretty easy and cool right?

Now watch this! By passing in a list of server names, the command will check all of the servers.

I create a list of servers and put it in the $ServerList variable. This will check the four servers in the list.


Now we run the Get-DbaDiskSpace command again and pass in $ServerList for the computername.

Get-DbaDiskSpace -ComputerName $ServerList

Can we sort this list somehow so we see servers with low disk space at the top? Yes! Just add the | out-gridview at the end of the statement.

Get-DbaDiskSpace -ComputerName $ServerList | out-gridview

That will pop this listing up, now just click the title heading “PercentFree” and that will sort the results. Now you can easily see which servers you need to turn your attention to.

Dbatools is a very handy addition for your tool belt. For doing administration against multiple servers, this is a very handy helping hand.

To read more about this command and other parameters you can use, please follow this link.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s