53 How to find multiple systems total, free and used disk space?

In the below PowerShell script:-

  1. Please change the path where this script you are going to save.
  2. Name the script as “Get-Disk_total_free_used_label.PS1”.
  3. Create one text file “computer”.
  4. In this text file, save the computer name (under computer.txt)  one per row.
  5. The output  CSV file will be created into the folder that you will specify.

Note:

  1. Only change the path that is highlighted below in bold with your folder path.
  2. Don’t add blank/null value or extra spacing while adding the computer names into the text file.
In case of any hurdle, please Contact Us
$inputpath = 'C:\Temp\IJ\Get_Disk_Size_Disk_Free_Space\input\computer.txt'
$outpath = 'C:\Temp\IJ\Get_Disk_Size_Disk_Free_Space\output\disk_Details.csv' 
del C:\Temp\IJ\Get_Disk_Size_Disk_Free_Space\output\disk_Details.csv -ErrorAction SilentlyContinue

$Computers = Get-Content -Path $inputpath
$Output = @()

Foreach ($Computer in $Computers)
{ 
Write-Progress -Activity "Collecting Information of" -Status $Computer -PercentComplete 35 -Verbose

$Output += Get-WmiObject Win32_Volume -Filter "DriveType='3'" -ComputerName $Computer | ForEach {
New-Object PSObject -Property @{
Computer = $Computer
DeviceID = $_.DeviceID
Label = $_.Label
DriveType = $_.DriveType
DriveLetter = $_.DriveLetter
TotalSize_GB = ([Math]::Round($_.Capacity /1GB,2))
FreeSpace_GB = ([Math]::Round($_.FreeSpace /1GB,2))
UsedSpace_GB = ([Math]::Round($_.Capacity /1GB,2)) - ([Math]::Round($_.FreeSpace /1GB,2))
}
Write-Progress -Activity "Collecting Information of" -Status $Computer -PercentComplete 100 -Verbose
}
}
$Output | Export-Csv -NoTypeInformation -Path $outpath 
invoke-item $outpath