Solved

Remove E-mails From Public Folders

Posted on 2014-10-30
6
1,525 Views
Last Modified: 2014-11-11
Hello Experts.  
To remove an e-mail from all mailboxes I use this command.

Get-Mailbox | Search-Mailbox -SearchQuery "From:'XXXX'" -LogOnly -TargetMailbox administrator  -TargetFolder Inbox
and
Get-Mailbox | Search-Mailbox -SearchQuery "From:'XXXX'" -DeleteContent.

This does not hit my Public Folders.   I am trying to write a basic command to also remove e-mails from Public Mail Enabled Folders.  

Get-PublicFolder | Search-Mailbox -SearchQuery "From:'XXX'" -LogOnly -TargetMailbox administrator -TargetFolder \research

Cannot process argument transformation on parameter 'Identity'. Cannot convert the "\" value of type "Microsoft.Exchange.Data.Mapi.PublicFolder Id" to type "Microsoft.Exchange.Configuration.Tasks.MailboxOrMailUserIdParameter".
    + CategoryInfo          : InvalidData: (Microsoft.Excha...pi.PublicFolder:PSObject) [Search-Mailbox], ParameterBin    din...mationException     + FullyQualifiedErrorId : ParameterArgumentTransformationError,Search-Mailbox

Any Suggestions ??

Thank you in advance for your assistance.
0
Comment
Question by:cnetwiz
6 Comments
 
LVL 7

Expert Comment

by:Satyendra Sharma
ID: 40414039
0
 

Author Comment

by:cnetwiz
ID: 40414130
Hello,
I already reviewed the first site.  
The purpose of this script is not to move but to delete a mail item from ALL public folders identified by similiar Subject or From as my example below shows:
Get-PublicFolder | Search-Mailbox -SearchQuery "From:'xxxx'" -LogOnly -TargetMailbox  administrator -TargetFolder "\Public Folders\All Public Folders\"

I can successfully run a smiliar script on the Exchange Mailboxes and it works perfectly.
Get-Mailbox | Search-Mailbox -SearchQuery "From:'XXXX'" -LogOnly -TargetMailbox administrator  -TargetFolder Inbox

When I run a Public Folder item,  I keep getting errors.  

I am trying to do the same thing but to the Public Folders.

Cannot process argument transformation on parameter 'Identity'. Cannot convert the "\" value of type "Microsoft.Exchange.Data.Mapi.PublicFolder Id" to type "Microsoft.Exchange.Configuration.Tasks.MailboxOrMailUserIdParameter".
     + CategoryInfo          : InvalidData: (Microsoft.Excha...pi.PublicFolder:PSObject) [Search-Mailbox], ParameterBin    din...mationException     + FullyQualifiedErrorId : ParameterArgumentTransformationError,Search-Mailbox
0
 
LVL 27

Accepted Solution

by:
Steve earned 250 total points
ID: 40434554
you cannot just specify a top level public folder (ie "\") as exchange has no way to translate that to the entire folder structure.

try getting the command to work on a specific folder first to check the command will actually work as you want it to.

Then have a look at the Microsoft provided script that adds permissions to public folders:
AddUsersToPFRecursive.ps1 (should be in your scripts folder)

This Powershell script actually gets a full public folder list and then applies the required permission to each folder one at a time.
To achieve what you need you'll have to do the same by recursively searching each folder. Use AddUsersToPFRecursive.ps1 as a starting point.
0
 
LVL 16

Assisted Solution

by:Rajitha Chimmani
Rajitha Chimmani earned 250 total points
ID: 40436056
You are getting this error as Search-Mailbox command works only against a mailbox and hence it does not recognize "\" as a valid object.

As I know, there is no direct command to delete items from a public folder using powershell. I have not seen one yet but I guess its possible through VB
0
 

Author Closing Comment

by:cnetwiz
ID: 40436117
I have discovered that deleting items from All Public Folders is not possible unless it is with a VB Script.   With the many Public Folders existing in our organizaiton, I will open a Pay Ticket with Microsoft to see what tricks they have up their sleeves.   I will gladly post any suggestions and resolutions from Microsoft here.     Thank you .
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

This process describes the steps required to Import and Export data from and to .pst files using Exchange 2010. We can use these steps to export data from a user to a .pst file, import data back to the same or a different user, or even import data t…
Following basic email etiquette rules will help you write a professional email and achieve a good, lasting impression with your contacts.
In this video we show how to create an email address policy in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.:  First we need to log into the Exchange Admin Center. Navigate to the Mail Flow…
In this video we show how to create a mailbox database in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Servers >> Data…

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now