Link to home
Start Free TrialLog in
Avatar of Stelian Stan
Stelian StanFlag for Canada

asked on

PowerShell Script

I want to create a script to change the permissions on multiple Public Folders based on a CSV file. I have a CSV file
PF-Chg.csv
Avatar of Will Szymkowski
Will Szymkowski
Flag of Canada image

Here is a powershell script that i created to add/modify permissions see below...

Note: the csv file you create needs to have the following column headings
- Name (Public Folder Name\location)
- User (User you want to grant access to)
- Access (Access level you want to give to the user)

Add-PSSnapin Microsoft.Exchange.Management.Powershell.Admin
$PFPerm = Import-Csv "c:\yourCSVhere.csv"
foreach ($PF in $PFPerm) {
$PF.Name
$PF.User
$PF.Access
Get-PublicFolder -Identity $PF.Name -Recurse | Add-PublicFolderClientPermission -User $PF.User -AccessRights $PF.Access
}

Open in new window

Another thing you can use is PFDAVadmin which is also a great tool to modify permissions for Public Folders.

Download - http://www.microsoft.com/en-ca/download/details.aspx?id=22427
Manual - http://technet.microsoft.com/en-us/library/bb508858(v=exchg.65).aspx

Thanks

Will.
Avatar of Stelian Stan

ASKER

On each PF I only need to change OldFC with NewFC and keep the same permissions.
Thank you Will for your quick response. I was thinking to use something like this:

$PFPerm = Import-Csv "C:\PF_Chg.csv"
foreach ($PF in $PFPerm) {ReplaceUserWithUserOnPFRecursive.ps1 -TopPublicFolder "'$PF.Name'" -UserOld $PF.OldFC -UserNew $PF.NewFC}

Open in new window


but I'm getting this error:
get-publicfolder : There is no existing PublicFolder that matches the following Identity: '@{Name=\Max Store Reports\store059; OldFC=MikeC; NewFC=BrianC}.Name'. Please make
sure that you specified the correct PublicFolder Identity and that you have the necessary permissions to view PublicFolder.

I need a way to read "\Max Store Reports\store059" for '$PF.Name
The below error message is referring to exactly what it says. It cannot find the Public Folder you have listed.

The -Identity parameter needs to have the GUID or Public Folder name that represents the public folder. Using the full path might help...

This is an example from the help in Powershell...
Get-PublicFolder -Identity "\Legal\Documents\Pending Litigation"
The Variable should not need "" around it. Try removing those. Also for the syntax it might only be looking for ""\Max Store Reports" as the toplevel PF.

Also take a look at the link below for more examples/syntax.
http://www.msexchange.org/articles-tutorials/exchange-server-2007/tools/using-exchange-sever-2007-built-in-scripts-part1.html
ASKER CERTIFIED SOLUTION
Avatar of Stelian Stan
Stelian Stan
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Worked for me.