** THIS SCRIPT IS PROVIDED WITHOUT WARRANTY, USE AT YOUR OWN RISK **
This script will take input of a list of computers from the computer.txt and query that computer for various harddrive information. The output is in an html file in and easy to read table format.
I have this running as a scheduled task on my servers once per week dumping the results to a fileshare.
Tested with Windows 7, Windows Vista, Windows Server 2003, Windows Server 2K8 and 2K8 R2.
# ** THIS SCRIPT IS PROVIDED WITHOUT WARRANTY, USE AT YOUR OWN RISK ** # DESCRIPTION # This script will take input of a list of computers from the computer.txt and query that # computer for various harddrive information. The output is in an html file in and easy to # read table format. # I have this running as a scheduled task on my servers once per week dumping the results to a fileshare. # REQUIREMENTS # 1. Nothing special that I know of other than maybe Set-Executionpolicy remotesigned. # NOTES #Tested with Windows 7, Windows Vista, Windows Server 2003, Windows Server 2K8 and 2K8 R2 #AUTHOR # David Hall | https://www.signalwarrant.com/ # Change the $path to whatever path you want. Your computers.txt will need to be in this folder. # The results.csv will also be pu in this folder once the script has run. $path = "C:\scripts\drive_info" $exportPath = "C:\scripts\drive_info" # I change this to a central fileshare $computers = gc $path\computers.txt # Start HTML Output file style $style = "<style>" $style = $style + "Body{background-color:white;font-family:Arial;font-size:10pt;}" $style = $style + "Table{border-width: 1px; border-style: solid; border-color: black; border-collapse: collapse;}" $style = $style + "TH{border-width: 1px; padding: 2px; border-style: solid; border-color: black; background-color: #cccccc;}" $style = $style + "TD{border-width: 1px; padding: 5px; border-style: solid; border-color: black; background-color: white;}" $style = $style + "</style>" # End HTML Output file style $driveinfo = Get-WMIobject win32_LogicalDisk -computername $computers -filter "DriveType=3" | Select-Object SystemName,DeviceID,@{Name="Size(GB)";Expression={"{0:N1}" -f($_.size/1gb)}},` @{Name="FreeSpace(GB)";Expression={"{0:N1}" -f($_.freespace/1gb)}},` @{Name="% FreeSpace(GB)";Expression={"{0:N2}%" -f(($_.freespace/$_.size)*100)}} $driveinfo | ConvertTo-HTML -head $style | Out-File $exportPath\server_drivespace.htm