Laeeq Qazi's Exchange Server Blog

Exchange Server blog

How to remove client permissions from a public folder and all its children?

Hi,

In Exchange 2007/2010 you can remove client permissions from a public folder and all its child public folders for all users in bulk using following script.

Suppose you have a root level public folder ‘\Sales’ on public folder server “Mailbox01″, which in turn has 2 child public folders ‘\Sales\Uk’ and ”\Sales\US’, then this script will remove all client permissions from these 3 public folders for all users.

########### Script Start #####################
$AllPublicFolders = Get-publicFolder ‘\Sales’ -recurse -server Mailbox01

foreach($Pf in $AllPublicFolders ){

Get-PublicFolderClientPermission $Pf | Foreach{ Remove-PublicFolderClientPermission $_.Identity -User $_.User -AccessRights $_.AccessRights }

}
########### Script End #####################

Note: Put above lines of code in a text file and save it as .ps1 (powershell) file and then execute it in Exchange Management Shell (EMS) or Windows Powershell console.

If you save this file in Exchange Scripts folder
“C:\Program Files\Microsoft\Exchange Server\Scripts” [Exchange 2007]
OR
“C:\Program Files\Microsoft\Exchange Server\V14\Scripts” [Exchange 2010]

then, in EMS, you will just need to enter the .ps1 file name and then press enter.

You might also need to set the powershell execution policy as RemoteSigned in EMS:

Set-ExecutionPolicy RemoteSigned

Also, if you decide to run this script in Windows Powershell Console then don’t forget to add powershell exchange snap-in using one of the following commands:

#For Exchange 2007:
Add-PSSnapIn “Microsoft.Exchange.Management.PowerShell.Admin”
#For Exchange 2010:
Add-PSSnapIn “Microsoft.Exchange.Management.PowerShell.E2010”

Note: For exchange 2013\Office 365, first line of script should be:

$AllPublicFolders = Get-publicFolder ‘\Sales’ -recurse

 

Regards,
Laeeq Qazi

Advertisements

June 27, 2010 - Posted by | Exchange 2007, Exchange 2010, Exchange 2013, Office 365

6 Comments »

  1. […] How to remove client permissions from a public folder and all its children? June 2010 […]

    Pingback by 2010 in review « Laeeq Qazi' Exchange Server 2007/2010 Blog | January 2, 2011 | Reply

  2. Hello,

    I Want to set permission as “None” for all the users on public folders which are inactive since last 180 days.

    Please do let me know if you have any poweshell script for this purpose

    Comment by Sandy | July 15, 2015 | Reply

    • Apology for late reply. I have no built-in solution for your requirement. You would have to use Get-MailboxStatistics command for each of the user-with-permission, before removing the permission.

      Comment by exchangegeek | October 5, 2015 | Reply

  3. Did not work on Office 365

    Comment by avi@avi.com | October 8, 2015 | Reply

    • Can you please post the error which you got?
      Also, did u run exact command as mentioned in this post?

      Comment by exchangegeek | October 8, 2015 | Reply

    • I just noticed that, my written command is not compatible with Exchange 2013 and o365.
      You have to replace this
      $AllPublicFolders = Get-publicFolder ‘\Sales’ -recurse -server Mailbox01
      with this
      $AllPublicFolders = Get-publicFolder ‘\Sales’ -recurse

      -Server parameter has been removed from Exchange 2013+ versions.

      Hopefully it would run.

      Comment by exchangegeek | October 8, 2015 | Reply


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: