Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Remove E-mails From Public Folders

Posted on 2014-10-30
6
1,864 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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to resolve IMCEAEX NDRs in Exchange or Exchange Online related to invalid X500 addresses.
The Nano Server Image Builder helps you create a custom Nano Server image and bootable USB media with the aid of a graphical interface. Based on the inputs you provide, it generates images for deployment and creates reusable PowerShell scripts that …
In this video we show how to create a Shared Mailbox 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 Recipients >> Sha…
This video discusses moving either the default database or any database to a new volume.

809 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