Link to home
Start Free TrialLog in
Avatar of wayy2be
wayy2be

asked on

Powershell Script Question for Exchange 2007

I have two cmdlets that I would like to run in a script that I can run instead of running each comdlet by itself. What I would like the script to do is to run the first cmdlet and after it is done, print a success message and then run the other cmdlet. I would also like to have it create a logfile of the time it started, actions it took and time ended. Can anyone help me with this?  

The cmdlets are :

get-mailbox –server mail | Export-Mailbox –SubjectKeywords "Discovery Keywords" –TargetMailbox Administrator –TargetFolder 'MyData'

get-mailbox –server mail | Export-Mailbox –ContentKeywords "Discovery Keywords" –TargetMailbox Administrator –TargetFolder 'MyData

Also does anyone know if the cmdlets will search all the information stores on Exchange?

Thanks,
Joe
ASKER CERTIFIED SOLUTION
Avatar of chrismerritt
chrismerritt

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of wayy2be
wayy2be

ASKER

Using this script will it search every information store on the server if there is more than one? Also will delete any of the emails that it finds? Thanks
I'm not sure why you term it as information store, Get-Mailbox will return all mailboxes unless you filter it with the -Server switch for example. If you want all mailboxes on a server then you can just change the line in my script on Line 42 so that it references whatever server you want.

If you want all mailboxes then as per my previous post, you can just omit the -Server switch completely.

No emails will be deleted because the Export-Mailbox command does not have -DeleteContent set to true, the command should be the same as the ones you posted originally.
Avatar of wayy2be

ASKER

Thanks. What is the best way to run this?  I am totally new to PowerShell.
SOLUTION
Avatar of Qlemo
Qlemo
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial