FN-GM Posted April 18, 2012 Posted April 18, 2012 Hi, I am setting up an exchange server. I have configured journaling, a copy of each email sent in the system goes to this mailbox. They just get dumped into the inbox. Does anyone know anything or have a system i can do to help tidy these up and manage these messages please? Thanks
eddyc Posted April 18, 2012 Posted April 18, 2012 At my last school we would make a new jounaling mailbox at the start of the year and dismount the old one and store it away from the server on a USB drive kept in a safe. Keeps each year seperate and off of the live server but allows them to be revisited as required.
FN-GM Posted April 18, 2012 Author Posted April 18, 2012 Well i was thinking about exporting .PST every month or so. There are 1,500 users so allot of mail going around.
ozydave Posted April 19, 2012 Posted April 19, 2012 Hello Exporting to pst every day is what I am doing at the mo. just a power shell script on a scheduled task. Works a treat Cheers
Edu-IT Posted April 19, 2012 Posted April 19, 2012 At the moment I do this each month but would be interested to see the script also.
ozydave Posted April 19, 2012 Posted April 19, 2012 Sorry not been able to grab 5 minutes yet. Will post it later tonight.
ozydave Posted April 19, 2012 Posted April 19, 2012 Hello Chaps / chapets Here is my power shell script $dtoday = get-date -format "dd-MM-yyyy" New-Item Y:\$dtoday -type directory -Force export-Mailbox -Identity [email protected] -PSTFolderPath y:\$dtoday\$dtoday.pst -DeleteContent -confirm:$false All it does is create a folder with todays date then exports the journal mailbox into that folder with a created pst with the same date. Normally export-mailbox to pst leaves the items in place (strange when the command is export) So the –deletecontent –confirm:$false does the deletion Save the script as .ps1 and run it from a scheduled task. You can run the script as many times a day as you need, it will only create one folder and pst per day. The machine you schedule the task on will need the exchange powershell snapin added. Hope this helps Cheers 1
FN-GM Posted May 20, 2012 Author Posted May 20, 2012 Thanks @ozydave what permissions does the user have who you run this under please? Thanks
ozydave Posted May 24, 2012 Posted May 24, 2012 Hello FN_GM Sorry not been on for a few days again. I am an exchange admin so i had to give myself full permissions on the journal mailbox first add-mailboxpermissions -identity [email protected] -user exchangeadmin -accessrights fullaccess This should do the trick Thanks
FN-GM Posted June 12, 2012 Author Posted June 12, 2012 I have finally got around to doing this. Do you have any thoughts on this error please? Thanks
ascott2 Posted June 12, 2012 Posted June 12, 2012 (edited) I have finally got around to doing this. Do you have any thoughts on this error please? You don't have the Exchange cmdlets loaded. Either run the script from the exchange management shell, or run a remote powershell session to the Exchange server. Edited June 12, 2012 by ascott2 forgot quote
FN-GM Posted June 12, 2012 Author Posted June 12, 2012 You don't have the Exchange cmdlets loaded. Either run the script from the exchange management shell, or run a remote powershell session to the Exchange server. I do have them loaded, i have also tried within the Exchange Management Shell. Please see the attached. Thanks
markcuk Posted June 12, 2012 Posted June 12, 2012 pretty sure the export-mailbox command was taken out exchange 2010 I was trying to export mailboxes last week. You have to use the following command New-MailboxExportRequest: Exchange 2010 Help 1
ascott2 Posted June 12, 2012 Posted June 12, 2012 I think you need to explicitly add the import export mailbox permission to the role before you can see the cmdlet. Take a look here Add the Mailbox Import Export Role to a Role Group: Exchange 2010 Help
FN-GM Posted June 12, 2012 Author Posted June 12, 2012 pretty sure the export-mailbox command was taken out exchange 2010 I was trying to export mailboxes last week. You have to use the following command New-MailboxExportRequest: Exchange 2010 Help This is it. Using this cmdlet how do i clear the mailbox after the export please?
ascott2 Posted June 12, 2012 Posted June 12, 2012 export-Mailbox has a -DeleteContent parameter which I think, deletes all the content after the export. It has been a while since I ran this, so double check before running.
markcuk Posted June 12, 2012 Posted June 12, 2012 How to delete emails on MS Exchange server 2010 SP1 | Tech Stuff
CAWJames Posted June 27, 2012 Posted June 27, 2012 I am trying to build this script in 2010 SP2, so have managed to adjust the command to use the new New-MailboxExportRequest but they have deprecated the -deletecontent command and moved it seemingly to the Search-Mailbox command. Which is all well and good for single operations. How do I mix this up into a script, as I assume if i call the first command and then the second, it wont wait for the export and just delete it all! Any help appreciated, I just want to export our journal mailbox out to pst once a month, and then clear down the mailbox. I thought about doing one command one day and then the other the next, but I'm always going to have some tween mails that happen between each command. This is doing my head in! Thanks James
FN-GM Posted June 28, 2012 Author Posted June 28, 2012 I am trying to build this script in 2010 SP2, so have managed to adjust the command to use the new New-MailboxExportRequest but they have deprecated the -deletecontent command and moved it seemingly to the Search-Mailbox command. Which is all well and good for single operations. How do I mix this up into a script, as I assume if i call the first command and then the second, it wont wait for the export and just delete it all! Any help appreciated, I just want to export our journal mailbox out to pst once a month, and then clear down the mailbox. I thought about doing one command one day and then the other the next, but I'm always going to have some tween mails that happen between each command. This is doing my head in! Thanks James @CAWJames Im sure we can help, please can you post the code for the script. If you dont mind i might "borrow" it
CAWJames Posted June 28, 2012 Posted June 28, 2012 After some long hours running around the more 'codier' parts of the net, I have a solution: $dtoday = get-date -format "dd-MM-yyyy" New-Item \\srv-id-009\MonitorArchive$\$dtoday -type directory -Force New-MailboxExportRequest -Mailbox Email_journal_user -FilePath \\srv-id-009\MonitorArchive$\$dtoday\$dtoday.pst while ((Get-MailboxExportRequest -Mailbox Email_journal_user | Where {$_.Status -eq "Queued" -or $_.Status -eq "InProgress"})) { sleep 60 } Get-MailboxExportRequest -Mailbox Email_journal_user | Remove-MailboxExportRequest -Confirm:$false Get-Mailbox -ID Email_journal_user | Search-Mailbox -SearchQuery 'subject:"*"' -deletecontent -force Both parts with a while loop in the middle. It still left about 17 emails in the box afterwards, but they are probably just things archived after the fact and the odd bit not covered by -SearchQuery 'subject:"*"'. Bold bits are the bits to change as they point to my system. Thanks, and hope this helps others, James
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now