Scripted change of calendar permissions

CASE 1: an existing Exchange user (mailbox) needs to be accessible for other users. This can be the ‘Inbox’ , ‘Calendar’ or other folders. For this case, go to BLOG DECEMBER 2008
CASE 2: we have a new user in our group and the rights for his/her mailbox settings have to be same as for another user. In this case go for EXPORT & IMPORT PERMISSIONS
CASE 3: the policy about the rights on all personnel calendar permissions change. Everyone has to be “Author” instead of “Reviewer”. If this is the case for EVERYONE, go to CHANGE PERMISSIONS MANUALLY. If the case is for a specific group, go to SCRIPTS
CASE 4: cases 1 and 2 are specific cases implemented at a specific time. Everything that changes after this momentum is not affected by these rules. For example; the calendar of a new mailbox user will not be shared as mentioned. Therefore you go to SCRIPTS 

===================================

PREPARATION

1) Download the PFDAVAdmin (Public Folders DAV Administration) files and copy them to a folder C:\Program Files\PFDavAdmin\ 

2) Download and install .NET Framework 1.1 first. Do not pass over this step even if you already have .NET Framework 2, 3 or higher.


REMARK: if you are planning to work with the scripts you have to prepare your environment on the exchange server itself because you will need de Exchange Management Shell for some scripts
===================================
EXPORT & IMPORT PERMISSIONS

1) Open PFDAVAdmin and connect to All Mailboxes
2) Select the subfolder of the source user. Go to TOOLS and select Export Permissions
3) Change the scope selection to Selected folder and subfolders and click OK
4) Open the .txt file you created. It should look something like:

# ************************************************************************
# Created with PFDAVAdmin 2.8
# dinsdag 17 februari 2009 16:44:52
#************************************************************************
#
# This export format is only usable with PFDAVAdmin 2.0 and later.
# ************************************************************************
SETACL Mailboxes\XtestHaDL\Top of Information Store\Calendar (AD security group) Reviewer NO


5) Change the mailbox alias. In this case change “XtestHaDL” to “HaDL” and save file.
6) Go to TOOLS and select Import
===================================

SCRIPTED IMPORT

At first we have to create a .CMD file which that will trigger the .PS1 script
On the next page you find the powershell script. If you want to automate this, just add the START.CMD to your scheduled tasks and run it every night.

START.CMD
if not exist C:\temp mkdir C:\temp
if exist C:\temp\getmailboxfile.txt del C:\temp\getmailboxfile.txt
if exist C:\temp\getmailboxfile2.txt del C:\temp\getmailboxfile2.txt
if exist C:\temp\importpermissions.txt del C:\temp\importpermissions.txt

CMD /C START C:\WINDOWS\system32\windowspowershell\v1.0\powershell.exe -PSConsoleFile “C:\Program Files\Microsoft\Exchange Server\bin\exshell.psc1” -command “.’C:\PFDAVAdmin\importpermissions.ps1′”

IMPORTPERMISSIONS.PS1
#======================================================================#

# VARIABLES
$OU = “CORPORATE_USERS”
$DOMAIN = “”
$ExchangeServer = “”
$ExchangeAdmin = “”
$Password = “”

$getmailboxfile = “C:\temp\getmailbox.txt”
$getmailboxfile2 = “C:\temp\getmailbox2.txt”
$importpermfile = “C:\temp\importpermissions.txt”
$String1 = ‘SETACL Mailboxes\’
$String2 = ‘\Top of Information Store\Calendar (AD security group) Reviewer NO’

#======================================================================#

# ———-   prepare environment ———- #
# see START.CMD

# ——– select all users mailboxes ——- #
# in this case we only apply the script to the users of OU “Corporate Users”
get-mailbox -OrganizationalUnit $OU | select ALIAS | 
export-csv $getmailboxfile -notypeinfo

# ——– remove first line from TXT ——- #
$a = get-content $getmailboxfile
$b = 1
do {$a[$b] | out-file $getmailboxfile2 -append ; $b = $b +1} 
while ($b -le $a.count -1)

# ——- set SETACL strings for case ——- #
cat $getmailboxfile2 | 
foreach { $_ -replace $_ ,”$string1$_$string2″ } |  
Out-File $importpermfile

# ———- run the import script ———- #
PFDAVAdmin.exe -import ´
-s $ExchangeServer ´
-scope mailboxes ´
-f $importpermfile ´
-user $ExchangeAdmin ´
-password $Password ´
-domain $DOMAIN
#======================================================================#

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.