This script was written using PowerShell v3.0, running on a windows 7 desktop and interfacing with exchange 2007 on a Windows 2003 serverįirst we need to establish a link to the EWS assembly, and define the exchange version. It also demonstrates several other PowerShell syntax items, including using # to start a comment line ` as continuation line character, as well as some other basic functions. This example sets up the EWS interface service, defines a process contacts function, then imports and loops through a CSV of contacts to be maintained. Return to Outlook and you can repeat step 2, this time creating. This will put all SMTP addresses on GAL entries, which were in your PAB in the Windows Address Book from OE. Below are the basics that allowed me to not only import new contacts into Exchange using PowerShell, but also to add the ability to maintain existing contacts. In the Address Book Import Tool dialog window, click on the Microsoft Exchange Personal Address Book, selecting Import afterward. We were replacing our VBScripts interfacing with exchange 2003/2007, and preparing to migrate into exchange 2010/2013. Much of the setup and preperation in my script below is similar to existing examples, but I put together the rest of the pieces and added the logic to work with contacts in a public folder structure. This works for any number of subfolders, and you can also use the same method to remove access rights.Existing examples of PowerShell scripts didn't seem to include all the pieces to successfully manage contacts in an exchange public folder. The user account has been given these rights to the root folder, IT, and all its subfolders. Note that we don’t need to specify the Identity in the Add-PublicFolderClientPermission because we piped that to it with the | command.Īnd there you go.
Get-PublicFolder –Identity “IT” –Recurse | Add-PublicFolderClientPermission –User pponzeka –AccessRights PublishingEditor So, now, how do we apply these permissions to the root folder, in this case IT, and all three subfolders, in this case Documents, Emails and Plans? Well, we use the piping command to pipe the entire list of folders to the Add-PublicFolderClientPermission command. The permission to add permission on a public folder was:Īdd-PublicFolderClientPermission –Identity “ Foldername” –user UserName –AccessRights PublishingEditorĪdd-PublicFolderClientPermission –Identity “IT” –User pponzeka –AccessRights PublishingEditor
The other three have IT listed, which means they are sub folders of IT. The PowerShell import process is implementing a loop ( ForEach ), by reading each row of the CSV file, creating the required contact object in Exchange Online and repeating the process over and over again until he reaches the last row in the CSV file. Notice the Parent Path? IT has listed, which means its a Top Level Folder in Public Folders. So the command should be Get-PublicFolder –Identity “IT” –Recurse That’s odd, we know there are three folders underneath, why doesn’t it list these? We need to add the – Recurse option to our command, so that it looks in the root, and everything underneath. The command used is Get-PublicFolder –Identity “IT” So, first, in the Exchange Management Shell, if we attempt to list the public folder IT, this is the result of what we’ll see. So, we have the IT public folder, and three subfolders: But, since the protocol it uses, WebDAV is no longer available in Exchange 2010, we no longer have this option. Requirements: This script requires Powershell 2.0.
The script reads from a CSV and then creates a contact with the appropriate fields using the Exchange Web Services Managed API. This works great, but what if we have several subfolders under IT, and we want to apply the same user permissions to all of the subfolders as well? A utility called PFDAVADMIN that was available from Microsoft used to allow you to do this, and it still works with Exchange 2007. Import-PFContacts The purpose of this script is to import contacts into a public folder on Exchange 2007 or 2010 from a CSV file. The command is: Add-PublicFolderClientPermission –Identity “ Foldername” –user UserName –AccessRights PublishingEditorįor instance, to add the user pponzeka to the folder IT with the Publishing Editor permission, the command would be the following: If you have a public folder that your working on, and you need to apply permissions to it using the Exchange Management Shell, its pretty easy.