How can I export calendar content using exchange shell?

cyberleo2000
cyberleo2000 used Ask the Experts™
on
I tried using the command below to try to remove a meeting from a calendar, but, although the script runs with no errors, nothing is exported and the meeting remains in the calendar. What am I doing wrong?

Export-Mailbox -id jsmith -SubjectKeywords "Goals Review" -IncludeFolders "\Calendar" -StartDate "5/3/2012" -EndDate "5/5/2012" -DeleteContent -Targetmailbox "ExchangeAdmin" -TargetFolder JeanSmith -Confirm:$false
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
Can you please let me know if you want to remove meeting or want to export mailbox to PST
Your command is to delete the content of calendar not exporting. If you want to export the content to PST or other mailbox, do not use -DeleteContent

link:http://technet.microsoft.com/en-us/library/bb266964(v=exchg.80).aspx

Author

Commented:
Yes, I want to delete the content from the mailbox's calendar. I was under the impression that a targetmailbox or PST file switch is required. I am running the command on the exchange server and I do not have outlook installed on the exchange server so I used the targetmailbox switch.

Author

Commented:
here is another example: Export-Mailbox -id jsmith -subjectkeywords "Pickup at Store" -IncludeFolders "\Calendar" -StartDate "04/19/2010" -EndDate "04/21/2010" -DeleteContent

I ran this to try and delete an appointment in jsmith's calendar with that subject and it did not work, but there were no errors.

Below is some the status output I received in the powershell window

Options                          : DeleteSourceContent
SourceForestCredential           :
TargetForestCredential           :
TargetFolder                     :
PSTFilePath                      :
RsgMailboxGuid                   :
RsgMailboxLegacyExchangeDN       :
RsgMailboxDisplayName            :
RsgDatabaseGuid                  :
StandardMessagesDeleted          : 0
AssociatedMessagesDeleted        : 0
DumpsterMessagesDeleted          : 0
MoveType                         : DeleteOnly
MoveStage                        : Completed
StartTime                        : 4/18/2012 1:43:10 PM
EndTime                          : 4/18/2012 1:43:15 PM
StatusCode                       : 0
StatusMessage                    : Messages have been deleted from the source mailbox.
ReportFile                       : E:\Program Files\Microsoft\Exchange Server\Logging\MigrationLogs\export-Mailbox20120
                                   418-134253-8595452.xml

Author

Commented:
below is the log file output

/18/2012 1:42:53 PM] [0] Executing Command: 'Export-Mailbox -id jsmith -subjectkeywords "Pickup at Store" -IncludeFolders "\Calendar" -StartDate "04/19/2010" -EndDate "04/21/2010" -DeleteContent'
[4/18/2012 1:42:55 PM] [0] Searching objects "jsmith" of type "ADUser" under the root "$null".
[4/18/2012 1:42:56 PM] [0] Previous operation run on global catalog server 'MYDCSERVER.MYDOMAIN.com'.
[4/18/2012 1:42:56 PM] [0] Processing object "amer.MYDOMAIN.com/US/HUB/ATL-01/Users/Fernandez, Leonardo".
[4/18/2012 1:42:56 PM] [0] Searching objects "MYEXCHANGESERVER" of type "Server" under the root "$null".
[4/18/2012 1:42:56 PM] [0] Previous operation run on domain controller 'MYDCSERVER.MYDOMAIN.com'.
[4/18/2012 1:42:57 PM] [0] Searching objects "MYEXCHANGESERVER\SG18\ME200-MS18" of type "MailboxDatabase" under the root "$null".
[4/18/2012 1:42:57 PM] [0] Previous operation run on domain controller 'MYDCSERVER.MYDOMAIN.com'.
[4/18/2012 1:43:07 PM] [0] Ending processing.
[4/18/2012 1:43:07 PM] [0] [jsmith] The operation has started.
[4/18/2012 1:43:07 PM] [0] [jsmith] Approving object.
[4/18/2012 1:43:10 PM] [0] [jsmith] Trying to open mailbox:
      szServerLegacyDN: /o=MYDOMAIN/ou=Exchange Administrative Group (FYDIBOHF23SPDLT)/cn=Configuration/cn=Servers/cn=MYEXCHANGESERVER
      szUserLegacyDN: /o=MYDOMAIN/ou=First Administrative Group/cn=Recipients/cn=jsmith
      szServer: MYEXCHANGESERVER.MYDOMAIN.com
[4/18/2012 1:43:10 PM] [0] [jsmith] Open mailbox succeeded.
[4/18/2012 1:43:10 PM] [0] [jsmith] The operation has finished.
[4/18/2012 1:43:10 PM] [0] [jsmith] The operation has started.
[4/18/2012 1:43:10 PM] [0] [jsmith] Approving object.
[4/18/2012 1:43:13 PM] [0] [jsmith] Opening source mailbox.
[4/18/2012 1:43:13 PM] [0] [jsmith] Trying to open mailbox:
      szServerLegacyDN: /o=MYDOMAIN/ou=Exchange Administrative Group (FYDIBOHF23SPDLT)/cn=Configuration/cn=Servers/cn=MYEXCHANGESERVER
      szUserLegacyDN: /o=MYDOMAIN/ou=First Administrative Group/cn=Recipients/cn=jsmith
      szServer: MYEXCHANGESERVER.MYDOMAIN.com
[4/18/2012 1:43:13 PM] [0] [jsmith] Open mailbox succeeded.
[4/18/2012 1:43:13 PM] [0] [jsmith] Moving messages.
[4/18/2012 1:43:13 PM] [0] [jsmith] Exporting messages.
[4/18/2012 1:43:13 PM] [0] [jsmith] Merging messages.
[4/18/2012 1:43:15 PM] [0] [jsmith] 0 items could not be moved to the target mailbox.
[4/18/2012 1:43:15 PM] [0] [jsmith] Messages moved. Closing connections.
[4/18/2012 1:43:15 PM] [0] [jsmith] The operation has finished.
Commented:
You can run below command to delete the contents of calendar

Get-Mailbox | Export-Mailbox -Identity -SenderKeywords -SubjectKeywords "enter keywords here" -IncludeFolders "\Calendar" -DeleteContent


Refer:
http://www.exchangeserverinfo.net/index.php?option=com_content&view=article&id=71:how-to-delete-calendar-item-of-exited-user&catid=25:exchange-2003&Itemid=34
From I did testing if you specified the -StartDate -EndDate, it will not exporting anything to PST/delete the content.

I try this code:

Export-Mailbox -id jsmith -SubjectKeywords "Goals Review" -IncludeFolders "\Calendar"  -PSTFolder D:\PSTname.pst

Open in new window


Don't look at EMS result or Export-Mailbox log 1st. Open the PST with Outlook. Click on Folder list then it will show the "Calendar". Changed the view to the Month for better view. Then you will see the output in PST calendar.

Once done, check the EMS and Log, you will see that 0 items could not be moved to the target mailbox, however actually it already export the content of the calendar.
I'm attached the screenshot of Outlook and the log file for your reference
OutlookResult.JPG
export-Mailbox.txt

Author

Commented:
Sending the exported data to a mailbox or pst file should not matter, the data should still be removed from the source mailbox. That said, I cannot use a PST file because I am running the command on the exchange server, hence, no Outlook.

Also, if I don't specifiy a Start and End date then all calendar items with that same subject will be removed. I only want to remove it from within that date range.
Are running on Exchange 2007 ? You can't run Export-Mailbox cmdlet on Exchange server.

To perform this procedure, the account you use must be delegated the following:
 Exchange Server Administrators role and local Administrators group for the source server and the target server
 
Full access to the source and target mailboxes
 

For more information about permissions, delegating roles, and the rights that are required to administer Exchange 2007, see Permission Considerations.

Also, before you perform this procedure, be aware of the following:
 To use the Export-Mailbox cmdlet, the source mailbox and target mailbox must be in the same forest. You cannot export data from a mailbox in one forest to a mailbox in a different forest.

You cannot export data from a public folder database.
 
To grant full access to a mailbox, use the Add-MailboxPermission cmdlet and specify FullAccess for the AccessRights parameter. For example, if Admin01 needs to export data from John's mailbox to a mailbox called Export, you must first run the following commands:






Copy


Add-MailboxPermission -Identity john -User Admin01 -AccessRights FullAccess
Add-MailboxPermission -Identity Export -User Admin01 -AccessRights FullAccess
 
To export data from an Exchange 2003 or Exchange 2000 mailbox, the account you use must be delegated the Exchange Administrator role for the administrative group in which the server resides.
 
To export data from a .pst file, you must run the Export-Mailbox cmdlet from a 32-bit computer that has the following installed:
 The 32-bit version of the Exchange management tools
 
Outlook 2003 Service Pack 2 (SP2) or Outlook 2007
 
For information about Exchange 2007 management tools 32-bit download, see Microsoft Exchange Server 2007 Management Tools (32-Bit).
 
If you export data to a folder in another mailbox, the target mailbox that you specify must exist before you run the command.


If you doesn't include -DeleteContent cmdlet, the data will not removed from source mailbox. Already tested.
Updated:

I run this cmdlet:

[PS] C:\>Export-Mailbox -Identity <username> -IncludeFolders \calendar -PSTFolderPat
h d:\test.pst -StartDate "01/01/2012" -EndDate "05/04/2012" -SubjectKeywords
"Google Email Implementation"

Open in new window


And result is  I'm able to export the data from \Calendar to PST. Yesterday, I did test the same cmdlet but the StartDate/Enddate was on previous year. It is failed to export to PST. Like above cmdlet, I specified this year, the output as screenshot.

So, if you don't one

Here code to delete:

[PS] C:\>Export-Mailbox -Identity suriya -IncludeFolders \calendar -StartDate "0
2/01/2012" -EndDate "03/01/2012" -SubjectKeywords "Email Migration Impact and Re
sources Dependency" -DeleteContent

Open in new window


it was successfull deleted, please refer to log
PST-2.JPG
Log.txt
Log-1.txt

Author

Commented:
I still do not understand why this command does not work?

Export-Mailbox -id jsmith -SubjectKeywords "Goals Review" -IncludeFolders "\Calendar" -StartDate "5/3/2012" -EndDate "5/5/2012" -DeleteContent -Targetmailbox "ExchangeAdmin" -TargetFolder JeanSmith -Confirm:$false
When the "Goals Review" occured? It is starting on 5/3/2012? Why I'm asking this because from I did testing, if  you want to delete the Meeting on calendar start which start on 3 May 2012. The StartDate must be 2 days before the actual date (3 May 2012). So the StartDate will be 5/1/2012.

Try to export to PST 1st. If it is working mean that your code is ok. From there, we can start using -DeleteContent.
Problem solved? What is your final cmdlet?

Author

Commented:
Export-Mailbox -id jsmith -SubjectKeywords "Goals Review" -IncludeFolders "\Calendar" -StartDate "5/3/2012" -EndDate "5/5/2012" -DeleteContent -Targetmailbox "ExchangeAdmin" -TargetFolder JeanSmith -Confirm:$false

It was not a problem with the cmdlet, it was a problem with the subject of the appointment, although I have no idea what that problem was. I ran the cmdlet against a number of other appointments and it worked just fine.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial