Drive Space Information

One of the scripts which I need to use on a daily basis. This is a basic function of the script to get information on drive space. We can take the result and get a report emailed as a table put into a web page, or simply export it as a CSV file and manipulate as per your need. Usually, I export it as CSV and do some manual manipulation to filter the data which I require. Planning to do some automation on it. I will update the post as I do it... Enjoy!!!

PowerShell script to report on drive space available on remote windows systems.
Get the Availbale Max, availabe drive space information remotely and report it to admins.
.PARAMETER ComputerName
Accepts a list of computer names or IP addresses
Get-DriveSpace -ComputerName Server1,server2
function Get-DriveSpace
# A computer name or list of computer names
[string[]]$ComputerName = 'localhost'
$outObject = @()
foreach ($computer in $ComputerName)
$tempObject = Get-WmiObject -Class win32_logicaldisk -ComputerName $computer -Filter "DriveType = 3" | `
Select-Object `
@{n='Size GB';e={"{0:N2}" -f ([math]::Round($_.Size/1GB))}},`
@{n='FreeSpace';e={"{0:N2}" -f ($_.FreeSpace /1GB)}},`
@{n='% Free Space';e={"{0:N2}" -f ($_.FreeSpace / $_.Size * 100)}}
$outObject += $tempObject
return $outObject


Popular posts from this blog

Check SQL Server Database Status

PowerShell and Azure Resource Graph

Static Code Analysis: Some Tools