Scheduled task PowerGUI and E-mailing PowerShell Scripts

Original article can be found here: http://telnet25.wordpress.com/2009/07/07/scheduled-task-powergui-e-mailing-ps-scripts-is-very-easy/

Addition reference form here: http://smtp25.blogspot.com/2009/06/send-mail-with-attachment-using.html

Now one of the most asked question how do I get this nice report (PS Script) e-mailed to distribution group with scheduled task, we have touched base on this in the past but we will go over one more time.

If you are not a scripting person this post is perfect for you, if you never script anything in your life you are reading right article, I am sure PowerGUI will make you love PS scripts keep reading

 

Script is attached below

image

After downloading the PS script open with PowerGUI Script editor

image

Now don’t forget to change the mail serve name to your own and click on the green arrow to run it

  • Verify the output as below
  • User Name       : Temp11
  • Department      : Temp Employee Office
  • Storage Group   : MAIL2\SG2\SG2-MB1
  • Total Size (MB) : 0
  • itemCount       : 10

 

image

Perfect now we need to add into PSCode a little bit, at the end of last line I will start typing Pipe and export as you see below

image

just because PowerGUI is very hand and smart it is already start helping me, by showing me the possible PS commands associating with export command, this is incredible useful and easy to learn, as you see there is another sub menu help window opened up helping me for my next command which will be “path”

image

If you loose this point your curser back to end of the command the window will re populate for you, same nice future continues to help as shown below

 

image

I finish as fallows

  • |export-csv -Path c:\report\UDSTI-Report.csv

image

after running the script I go back to my script folder to make sure the CSV file is in there

image

Here is my report

image

Now you have the report all you need to do is to run another script to e-mail this to yourself or a DL which is listed here

Send Mail With Attachment Using PowerGUI

image

one you get this working any report you wish to generate will be easy task for you.

As always all credits goes to PowerGUI, if you have not played with PowerGUI , click below link to download and start becoming PS master (-:

Support File(s):