This is a continuation to my earlier posts PowerShell Error Log File and Export and Email … Using Powershell. This is also a test of the WP.com Gist code snippet support. The following script sample is intended to provide ideas for collecting exception output from a PowerShell script in a log file and then optionally emailing the error log to yourself (conditional on the success or failure status of your script). This type of script error log wrapper would typically be scheduled to run through Windows Task Scheduler to automate something repetitive.
Important cmdlets used include
Send-MailMessage. This also features the use of Automatic Variable