Subscribe to RSS feed  Follow @jackvamvas - Twitter

*Use the Comments section for questions Links


SQL Server DBA Jobs

How to get disk capacity from remote server using Powershell Get-PSDrive

10 May,2021 by Tom Collins

Question: I capture drive space details for capacity planning  servers hosting SQL Server. The SQL Server policies on the organisations restrict the use of xp_cmdshell - which allows access to server information as an administrator. Increasing servers are locked down to decrease the surface area of attack. Are there methods using Powershell which support remote gathering of drive details?


Answer: Powershell does support gathering drive information on remote servers , using Get-PSDrive . But I want to offer at the same time a word of caution related to the very point you are making in your question.

You've mentioned organisations securing server assets further - particuarly in light of cyber attacks and some other high profile Ransomware attacks of recent years. In applying any remote gathering of server data consider the security consequences. 

Back to the question of whether Powershell supports remote access of remote server drive information . This is an example of how to Invoke a command - wrapping Get-PSDrive - and executing on a remote server. 


Invoke-Command -ComputerName myserver1 {Get-PSDrive | Where {$_.Free -gt 0}}


--the command above returns a resultset with these columns

Name | Used (GB)  |Free (GB)  | Provider | Root | CurrentLocation | PSComputerName


Read more on Powershell 

Expand your Powershell mind – Three key cmdlets (SQL Server DBA)

3 methods to get the drive sizes with Powershell

Author: Tom Collins (


Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.


Post a comment on How to get disk capacity from remote server using Powershell Get-PSDrive | SQL Server Performance Tuning | SQL Server DBA:Everything | FAQ | Contact|Copyright & Disclaimer