1. We need to download and install the EWS API from the below link.
http://www.microsoft.com/en-in/download/details.aspx?id=353712. We then need create personal tag with the action set to move to archive with retention disabled or never set to expire. We then need to add this personal tag to the retention policy applied on the mailbox for the users.
3. We then need to provide application impersonation role to the admin account that will be used for running the script. We can create a new role group and ad the ApplicationImpersonation role to the group and then add the required administrator to the group or we can directly assign the role to the designated user
New-ManagementRoleAssignment “AssignmentName” -Role ApplicationImpersonation -User “username”
4. We then need to create a txt file with the name as UserAccounts.txt which should contain UPN or the SMTP address of the users. The format of the txt file should be as below.
WindowsEmailAddress
User1@domain.com
User2@domain.com
5. We then need to open the attached script and make the necessary modifications
a. Specify a location for the log file along with the name of the file by searching for the below parameter in the script.
[string]$LogFile = “C:\Temp\Log.txt”
b. Run get-retentionpolicytag “name of the tag” | fl retentionID and then make a note of the ID and place the ID in the below parameter in the script.
$ArchiveTagGUID = new-Object Guid(“{7a6b03d8-b5a4-46a6-a1e2-0cdb57daab69 }”)
c. We then need to specify the credentials which will be used for connecting to the EWS endpoint by searching for the below parameter in the script.
$service.Credentials = new-object Microsoft.Exchange.WebServices.Data.WebCredentials(“JohnDoe@Contoso.onmicrosoft.com”,”Password”,”
Contoso.onmicrosoft.com”)
d. Currently the script is set to apply the tag to the calendar folder. If this needs to be changed to Tasks then we need to search for the below parameter in the script.
#Change the name of the folder
$FolderName = "Calendar";
We can then execute the script which will apply the tag to the users listed in the txt file. To validate whether the tag has been applied we need to make use of MFCMAPI and follow the below steps.
1. Go to tools à Options à “Use MDB_Online flag when using OpenMsgStore
2. We then need to Session à Logon and the select the appropriate Outlook profile.
3. Right Click on the user mailbox and select open store and expand Root Container à Top of information Store à Calendar or Tasks
4. On right hand side search for PR_ARCHIVE_TAG, PidTagArchiveTag, ptagArchiveTag and check to see if this populated with a value which should look like below. This can be converted to the retentionid on the tag
D8036B7AA4B5A646A1E20CDB57DAAB69
First 8 characters need to reversed which will provide the starting portion of the retentionid
D8036B7A : 7A6B03D8
Next 4 Digits needs to reversed in the same fashion
A4B5 : B5A4
Same goes for the next 4 Digits
A646 : 46A6
Next 4 Digits should be kept as it is
A1E2
Last 12 Digits will be the last 12 Digits of the retentionID
0CDB57DAAB69
7a6b03d8-b5a4-46a6-a1e2-0cdb57daab69 : 7A6B03D8 B5A4 46A6 A1E2 0CDB57DAAB69
5. We can also search for the attribute PR_ARCHIVE_PERIOD, PidTagArchivePeriod, ptagArchivePeriod which should have a value of 0 which means retention action is disabled on the tag.