stripping out attachments while leaving the email record
i've seen this thread:
http://social.technet.microsoft.com/Forums/en-SG/exchangesvradmin/thread/ad634759-a112-4b7f-a8e1-46d0a2d97d16
and it appears this is not possible (to do in bulk). just checking if there may have been any developments on the issue. it would be a great feature to have since you can do this manually per message.
~~~ if this were /. this would be funny
September 6th, 2012 10:00am
I'm not sure which part of the page you linked to you are most interested in using (since it contains a few links of its own). But if you are interested in the Export-Mailbox bit, you may be able pipe the output of Get-MailboxDatabase to it, liked
this:
Get-MailboxDatabase | Export-Mailbox (followed by whatever parameters remove the attachments)
This (if it works) will do ALL mailboxes, though. Not sure if that's what you want. Test the parameters on a single mailbox first - you don't want to completely empty them all.Mobile OWA For Smartphone
www.leederbyshire.com
email a@t leederbyshire d.0.t c.0.m
Free Windows Admin Tool Kit Click here and download it now
September 6th, 2012 10:07am
I'm not sure which part of the page you linked to you are most interested in using (since it contains a few links of its own). But if you are interested in the Export-Mailbox bit, you may be able pipe the output of Get-MailboxDatabase to it, liked
this:
Get-MailboxDatabase | Export-Mailbox (followed by whatever parameters remove the attachments)
This (if it works) will do ALL mailboxes, though. Not sure if that's what you want. Test the parameters on a single mailbox first - you don't want to completely empty them all.Mobile OWA For Smartphone
www.leederbyshire.com
email a@t leederbyshire d.0.t c.0.m
September 6th, 2012 10:17am
Actually, Get-Mailbox might do it too, instead of Get-MailboxDatabase.Mobile OWA For Smartphone
www.leederbyshire.com
email a@t leederbyshire d.0.t c.0.m
Free Windows Admin Tool Kit Click here and download it now
September 6th, 2012 10:27am
i guess i was referring to the entire thread as it seemed to come to the resolution that the "whatever parameters remove
the attachments" thing you referred to does not exist. you can -DeleteContent but that removed the email record.~if this were /. this sig would be funny
September 6th, 2012 10:40am
Oh, right. I thought you'd found that a suggestion in that thread that worked on a single mailbox, and you were looking for a way to get it to run on all mailboxes. Or did you mean that you'd found a way to do it on a single message (as
per your last sentence in your original post), and were looking for a way to do it to an entire mailbox? I guess I'm not sure what your 'in bulk' means now. Does it mean an entire mailbox, or all mailboxes?Mobile OWA For Smartphone
www.leederbyshire.com
email a@t leederbyshire d.0.t c.0.m
Free Windows Admin Tool Kit Click here and download it now
September 6th, 2012 10:46am
You will have to use EWS to strip the attachment. Here's an example in thread at end of this post that copies the attachment to a network share, since you want to remove and not copy you will need to replace this snippet. You can post in the dev
forum for guidance.
foreach($attach in $miMailItems.Attachments){
$attach.Load()
$fiFile = new-object
System.IO.FileStream(($downloadDirectory
+ \ + $attach.Name.ToString()),
[System.IO.FileMode]::Create)
$fiFile.Write($attach.Content,
0, $attach.Content.Length)
$fiFile.Close()
write-host "Downloaded Attachment : "
+ (($downloadDirectory
+ \ + $attach.Name.ToString()))
Replace with
foreach (Attachment attachment
in message.Attachments)
{
message.Attachments.Remove(attachment);
break
}
Powershell script to get all new attachments and store them on a network share
http://social.technet.microsoft.com/Forums/is/exchange2010/thread/c4d4cca8-2bc0-48a9-97f8-61fc68c8079c
Deleting attachments by using the EWS Managed API
http://msdn.microsoft.com/en-us/library/exchange/dd633682(v=exchg.80).aspx
James Chong MCITP | EA | EMA; MCSE | M+, S+ Security+, Project+, ITIL msexchangetips.blogspot.com
September 6th, 2012 11:25am
On Thu, 6 Sep 2012 13:50:19 +0000, can_i_bum_a_sig wrote:
>
>
>i've seen this thread:
>
>http://social.technet.microsoft.com/Forums/en-SG/exchangesvradmin/thread/ad634759-a112-4b7f-a8e1-46d0a2d97d16
>
>and it appears this is not possible (to do in bulk). just checking if there may have been any developments on the issue. it would be a great feature to have since you can do this manually per message.
It may not be possible using a cmdlet, but it's possible to do:
http://msdn.microsoft.com/en-us/library/exchange/dd633682(v=exchg.80).aspx
The examples are given in C#. I don't know if the same thing is
possible in Powershell, but I expect it is.
---
Rich Matheisen
MCSE+I, Exchange MVP
--- Rich Matheisen MCSE+I, Exchange MVP
Free Windows Admin Tool Kit Click here and download it now
September 6th, 2012 5:36pm
After looking at the linked posts, I spent a bit of time and put some script together. Trouble is, I've only partially tested it (because I don't want to delete all of the attachments in all my mailboxes). Let me know if you want
to try it, and we'll go through some of the things you should be aware of before you try it.
Import-Module -Name "C:\Program Files\Microsoft\Exchange\Web Services\1.1\Microsoft.Exchange.WebServices.dll"
$credentials = New-Object Microsoft.Exchange.WebServices.Data.WebCredentials(USERNAME, PASSWORD)
$service = New-Object Microsoft.Exchange.WebServices.Data.ExchangeService
$service.Credentials = $credentials
$service.Url = "https://localhost/ews/exchange.asmx"
$mailboxes = Get-Mailbox
$folderFilter = New-Object Microsoft.Exchange.WebServices.Data.SearchFilter
$folderView = New-Object Microsoft.Exchange.WebServices.Data.FolderView(1000)
$folderView.Traversal = [Microsoft.Exchange.WebServices.Data.FolderTraversal]::Deep
$itemFilter = New-Object Microsoft.Exchange.WebServices.Data.SearchFilter+IsEqualTo([Microsoft.Exchange.WebServices.Data.EmailMessageSchema]::HasAttachments, $true)
$itemView = New-Object Microsoft.Exchange.WebServices.Data.ItemView(10000)
foreach ($mailbox in $mailboxes)
{
write-host $mailbox.displayName
$folderId = New-Object Microsoft.Exchange.WebServices.Data.FolderId([Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::MsgFolderRoot, $mailbox.primarySmtpAddress.ToString())
$folder = [Microsoft.Exchange.WebServices.Data.Folder]::Bind($service, $folderId)
$folders = $service.FindFolders($folderId, $folderFilter, $folderView)
foreach ($subFolder in $folders.Folders)
{
write-host $subFolder.displayName
$items = $subFolder.FindItems($itemFilter, $itemView)
foreach ($item in $items.Items)
{
write-host $item.subject
$item.Load()
foreach($attachment in $item.Attachments)
{
write-host $attachment.Name.ToString()
$item.Attachments.Remove($attachment)
break
}
$item.Update([Microsoft.Exchange.WebServices.Data.ConflictResolutionMode]::AutoResolve)
}
}
}
Mobile OWA For Smartphone
http://www.leederbyshire.com/
email a@t leederbyshire d.0.t c.0.m
September 7th, 2012 9:17am
wow - thanks Lee! after doing some research i've found that the user is well within the size and total item per folder limits, so i don't think i need to perform this task. (also i'm just a CAD manager here and only know enough about exchange
to get me in trouble (also, enough to know i shouldn't touch anything :))) <- and i know LISP ;)
but thanks for the effort, i'm sure someone will find it useful.~if this were /. this sig would be funny
Free Windows Admin Tool Kit Click here and download it now
September 7th, 2012 9:51am
S'okay - it was an interesting thing to play with.Mobile OWA For Smartphone
www.leederbyshire.com
email a@t leederbyshire d.0.t c.0.m
September 7th, 2012 9:59am