Report Schedule Use Script Powershell

Posted: August 23, 2016 in Windows

clip_image002

Download Scritp powershell from https://gallery.technet.microsoft.com/scriptcenter/Disk-Space-Report-Reports-98e64d65

  • Edit :

# EMAIL PROPERTIES

# Set the recipients of the report.

$users = YourDistrolist@company.com

# REPORT PROPERTIES

# Path to the report

$reportPath = "D:\Jobs\DiskSpaceQuery\Reports\";

# Get computer list to check disk space

$computers = Get-Content "servers_c.txt";

# Send Notification if alert $i is greater then 0

if ($i -gt 0)

{

foreach ($user in $users)

{

        Write-Host "Sending Email notification to $user"

$smtpServer = "MySMTPServer"

$smtp = New-Object Net.Mail.SmtpClient($smtpServer)

$msg = New-Object Net.Mail.MailMessage

$msg.To.Add($user)

$msg.From = "myself@company.com"

$msg.Subject = "Environment DiskSpace Report for $titledate"

$msg.IsBodyHTML = $true

$msg.Body = get-content $diskReport

$smtp.Send($msg)

$body = ""

    }

  }

=============================================================================

clip_image003

Create Task Schedule Report

https://blogs.technet.microsoft.com/heyscriptingguy/2012/08/11/weekend-scripter-use-the-windows-task-scheduler-to-run-a-windows-powershell-script/

clip_image005

clip_image006

clip_image007

clip_image008

Program/script :

Powershell

Add arguments (optional) : -file "E:\SETUP\Script\Disk Report\CheckDiskSpace_post.ps1"

CMIIW, Thanks Smile

Leave a Reply

Your email address will not be published. Required fields are marked *