Solved

schedule powershell script

Posted on 2011-03-08
4
630 Views
Last Modified: 2012-08-13
I am very new to powershell.  I was given the below command to export any mail that has specific keywords in it.  It works great, but I need it to run a lot of different searches, and wanted to script it so that I didn't have to babysit it.  How do i script it when it asks for a folder to put the messages in?  It also asks to confirm for all mailboxes.  I would also like to schedule this to run in the evening, so any help with scheduling it would be great, but I am guessing that I can figure that part out.

Get-mailboxdatabase –identity special | get-mailbox | export-mailbox –subjectkeywords “search” –targetmailbox mailbox
0
Comment
Question by:norwoodhelpdesk
  • 2
  • 2
4 Comments
 
LVL 27

Expert Comment

by:KenMcF
Comment Utility
You can add -targetfolder to your script

And to schedule you can save this a .PS1 file and add this line

add-pssnapin *EX*
Get-mailboxdatabase –identity special | get-mailbox | export-mailbox –subjectkeywords “search” –targetmailbox mailbox -targetfolder c:\mailboxes

Then create a schedule task. it should be like this if your .PS1 file is named exportmailbox.ps1

powershell.exe c:\exportmailbox.ps1



0
 

Author Comment

by:norwoodhelpdesk
Comment Utility
Thanks, i will try it out.  I do have a few more questions.

It also prompts for confirmation, and I choose A for all.  Will this still need me to enter that?

also, what is the C:\mailboxes for?  I don't want it in a PST, I just want it in a mailbox that is on the server.

0
 
LVL 27

Accepted Solution

by:
KenMcF earned 500 total points
Comment Utility
Sorry, I had the syntax wrong. The target folder should be the folder in the mailbox not on the lcoal drive. So change that to the folder in your destination mailbox.

You can add -confirm:$False to that so it will not prompt.
0
 

Author Comment

by:norwoodhelpdesk
Comment Utility
Worked great.  Thanks so much.
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

The article will show you how you can maintain a simple logfile of all Startup and Shutdown events on Windows servers and desktops with PowerShell. The script can be easily adapted into doing more like gracefully silencing/updating your monitoring s…
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now