Solved

schedule powershell script

Posted on 2011-03-08
4
646 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 27

Expert Comment

by:KenMcF
ID: 35070352
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
ID: 35070704
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
ID: 35070810
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
ID: 35070972
Worked great.  Thanks so much.
0

Featured Post

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I thought I'd write this up for anyone who has a request to create an anonymous whistle-blower-type submission form created using SharePoint 2010 (this would probably work the same for 2013). It's not 100% fool-proof but it's as close as you can get…
Windows 10 came with  a lot of built in applications, Some organisations leave them there, some will control them using GPO's. This Article is useful for those who do not want to have any applications in their image (example:me).
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

726 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