Hello,
Trying to get a quick help. Need to get w3wp.exe process memory consumption in GB and send the info via an email. Here is the pseudo code:
$serverlist = c:\temp\serverlist.txt
Get-Process --ComputerName $serverlist -Name w3wp | Out-File -FilePath c:\temp\test.txt
$From = "EmailAddress@gmail.com"
$To = "address1@abcde.com;address2@abcde.com;address3@abcde.com"
$Attachment = "C:\temp\test.txt"
$Subject = "Process Info"
$currenttime=Get-Date
$Body = "Please see attached file for more info about IIS process taken at"$currenttime
$SMTPServer = "smtp.gmail.com"
$SMTPPort = "587"
Send-MailMessage -From $From -to $To -Subject $Subject -Body $Body -SmtpServer $SMTPServer -port $SMTPPort -Attachments $Attachment
Once the code works, I would like to schedule it to run inside the task scheduler of windows server and run it at scheduled intervals which means, the user is logged off when the script runs in the background.
Will greatly appreciate your help on this.
Thanks.
Victor
Get Process Info, capture it and send it via email
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Re: Get Process Info, capture it and send it via email
you can use the Task Scheduler's "Run As" option to provide username & password.
This will help to run the script even if no one is logged on
This will help to run the script even if no one is logged on