Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Disk usage report by email prog?

Options
  • 24-12-2012 7:47am
    #1
    Posts: 0 ✭✭✭ Taylor Gray Teacher


    Does anybody know of a program that can be set to email me a disk usage report at regular intervals from a remote computer please? Something like this:

    http://www.ehow.com/how_8449867_send-email-linux-command-line.html

    but for Windows (7)? If there's nothing then anything that can email me a directory/folder listing at a regular internal would suffice. Thanks and Merry Christmas! :)


Comments

  • Registered Users Posts: 1,731 ✭✭✭GreenWolfe


    I was having a look at this Powershell script to get free space on each drive, and send the resulting HTML file as an email. It could stand some cleaning up, but it might be useful.
    # ----------------------------------------------------------------------------- 
    # Script: HTML_Uptime_FreespaceReport.ps1 
    # Author: ed wilson, msft 
    # Date: 08/07/2012 15:11:03 
    # Keywords: Scripting Techniques, Web Pages and HTAs 
    # comments: added freespace to the script  
    # Get-Wmiobject, New-Object, Get-Date, Convertto-HTML, Invoke-Item 
    # HSG-8-7-2012, HSG-8-8-2012
    # -----------------------------------------------------------------------------
    # Edited: 24/12/2012
    # Author: EP
    # -----------------------------------------------------------------------------
    
    Param( 
      [string]$path = "c:\development\uptimeFreespace.html", 
      [array]$servers = @("localhost") 
    )
    
    # Delete current html report file if it exists
    IF (Test-Path $path){
    	Remove-Item $path
    }
    
    Function Get-UpTime 
    { Param ([string[]]$servers) 
      Foreach ($s in $servers)  
       {  
         $os = Get-WmiObject -class win32_OperatingSystem -cn $s  
         New-Object psobject -Property @{computer=$s; 
           uptime = (get-date) - $os.converttodatetime($os.lastbootuptime)} 
            } #end foreach $s     
           } #end function Get-Uptime 
     
    Function Get-DiskSpace 
    { 
     Param ([string[]]$servers) 
      Foreach ($s in $servers)  
       {  
         Get-WmiObject -Class win32_volume -cn $s | 
           Select-Object @{LABEL='Comptuer';EXPRESSION={$s}}, 
             driveletter, label,  
             @{LABEL='GBfreespace';EXPRESSION={"{0:N2}" -f ($_.freespace/1GB)}} 
        } #end foreach $s 
    } #end function Get-DiskSpace 
     
    # Entry Point *** 
     
    $upTime = Get-UpTime -servers $servers |  
    ConvertTo-Html -As Table -Fragment -PreContent " 
      <h2>Server Uptime Report</h2> 
      The following report was run on $(get-date)" | Out-String 
     
    $disk = Get-DiskSpace -servers $servers |  
    ConvertTo-Html -As Table -Fragment -PreContent " 
      <h2>Disk Report</h2> "| Out-String   
        
    ConvertTo-Html -PreContent "<h1>Server Uptime and Disk Report</h1>" ` -PostContent $upTime, $disk >> $path  
     Invoke-Item $path
    # Construct Email
    $EmailFrom = "EMAIL_ADDRESS_1"
    $EmailTo = "EMAIL_ADDRESS_2" 
    $Subject = "Disk Usage Notification" 
    $Body = (Get-Content $path)
    $SMTPServer = "EMAIL_SMTP_ADDRESS"
    $SMTPServerPort = "587"
    $emailMessage = New-Object System.Net.Mail.MailMessage($EmailFrom,$EmailTo,$Subject,$Body)
    $emailMessage.IsBodyHtml = $true
    
    # Email user details
    $user = "USER_NAME_HERE"
    $pass = "PASSWORD_HERE"
    
    # Send email
    $SMTPClient = New-Object System.Net.Mail.SmtpClient( $SMTPServer , $SMTPServerPort)
    $SMTPClient.EnableSsl = $true
    $SMTPClient.Credentials = New-Object System.Net.NetworkCredential( $user , $pass );
    $SMTPClient.Send( $emailMessage )
    

    You could run it as a scheduled task -
    http://blogs.technet.com/b/heyscriptingguy/archive/2012/08/11/weekend-scripter-use-the-windows-task-scheduler-to-run-a-windows-powershell-script.aspx

    If your Windows box is stopping you from running PS scripts - http://technet.microsoft.com/en-us/library/ee176949.aspx

    Edit: don't forget to replace the all caps params in my script with your own values. I tested this script with my gmail account.


  • Posts: 0 ✭✭✭ Taylor Gray Teacher


    thanks mate. I came across something about powershell and an application called DU.exe whilst googling. I'm embarrassed to say I've never heard of either before. Must have another look at it (if I can find it!) :)

    :edit: http://www.vuzzlevuzz.org/2011/09/automated-disk-usage-reports-with.html


  • Registered Users Posts: 894 ✭✭✭Dale Parish


    Not sure if it's exactly what you're looking for but we use Monitis to monitor our servers daily....


Advertisement