Getting paraoid about free space on your disks? Try logging it

This just runs on the local computer and reports on remaining space of local disks.

This is powershell, so save as e.g. Get-free-space.ps1

$logfilepath = "$env:userprofile\Desktop\Diskspace.log"

function WriteToLogFile ($message)
{
   Add-content $logfilepath -value $message #append to log file
}

while ($true) 
    {
    $date = Get-Date -DisplayHint Date
    #$date = Get-Date -Format yyyy-MM-dd-HH-mm
    write-host $date  $env:computername "Disk Space logger" -BackgroundColor White -ForegroundColor Black
    writetologfile ($env:computername + " Diskpace " + $date)
    writetologfile (Get-CimInstance -ClassName Win32_LogicalDisk | Select-Object -Property DeviceID,@{'Name' = 'FreeSpace (GB)'; Expression= { [int]($_.FreeSpace / 1GB) } })
    write-host "Freespace written to logfile on Desktop. Re-running in 60 seconds"
    sleep 60
    }