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