The peoples hub is one of the new features in Exchange 2013 and Exchange Online that is aimed at making your life richer. One little quirk if your creating new folders using EWS is that they won't appear in the My Contacts list inOWA eg if I was creating a folder named aNewContactsFolder you would get
To make the new Folder you just created appear in the MyContacts list rather then other contacts you need to set these two yet to be documented properties
PeopleHubSortGroupPriority
PeopleHubSortGroupPriorityVersion
Setting the value of these two named properties to 5 and 2 respectively will make the folder appear under My Contacts, if you want to move the folder into other contacts set the values to 10 and 2
Here's a sample script to create a New Folder as a subfolder of a Mailboxes Contacts Folder and set these two properties so the Contact Folder appears under MyContacts
To run the script pass the emailaddress of the mailbox you want to run it against as the first parameter and the foldername as the second parameter eg use something like .\createMyContactsFldv2.ps1 jcool@domain.com newfolderss
I've put a download of this script here the script itself looks like.
To make the new Folder you just created appear in the MyContacts list rather then other contacts you need to set these two yet to be documented properties
PeopleHubSortGroupPriority
PeopleHubSortGroupPriorityVersion
Setting the value of these two named properties to 5 and 2 respectively will make the folder appear under My Contacts, if you want to move the folder into other contacts set the values to 10 and 2
Here's a sample script to create a New Folder as a subfolder of a Mailboxes Contacts Folder and set these two properties so the Contact Folder appears under MyContacts
To run the script pass the emailaddress of the mailbox you want to run it against as the first parameter and the foldername as the second parameter eg use something like .\createMyContactsFldv2.ps1 jcool@domain.com newfolderss
I've put a download of this script here the script itself looks like.
- ## Get the Mailbox to Access from the 1st commandline argument
- $NewFolderName = $args[1]
- $MailboxName = $args[0]
- ## Load Managed API dll
- ###CHECK FOR EWS MANAGED API, IF PRESENT IMPORT THE HIGHEST VERSION EWS DLL, ELSE EXIT
- $EWSDLL = (($(Get-ItemProperty -ErrorAction SilentlyContinue -Path Registry::$(Get-ChildItem -ErrorAction SilentlyContinue -Path 'Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Exchange\Web Services'|Sort-Object Name -Descending| Select-Object -First 1 -ExpandProperty Name)).'Install Directory') + "Microsoft.Exchange.WebServices.dll")
- if (Test-Path $EWSDLL)
- {
- Import-Module $EWSDLL
- }
- else
- {
- "$(get-date -format yyyyMMddHHmmss):"
- "This script requires the EWS Managed API 1.2 or later."
- "Please download and install the current version of the EWS Managed API from"
- "http://go.microsoft.com/fwlink/?LinkId=255472"
- ""
- "Exiting Script."
- exit
- }
- ## Set Exchange Version
- $ExchangeVersion = [Microsoft.Exchange.WebServices.Data.ExchangeVersion]::Exchange2010_SP2
- ## Create Exchange Service Object
- $service = New-Object Microsoft.Exchange.WebServices.Data.ExchangeService($ExchangeVersion)
- ## Set Credentials to use two options are availible Option1 to use explict credentials or Option 2 use the Default (logged On) credentials
- #Credentials Option 1 using UPN for the windows Account
- $psCred = Get-Credential
- $creds = New-Object System.Net.NetworkCredential($psCred.UserName.ToString(),$psCred.GetNetworkCredential().password.ToString())
- $service.Credentials = $creds
- #Credentials Option 2
- #service.UseDefaultCredentials = $true
- ## Choose to ignore any SSL Warning issues caused by Self Signed Certificates
- ## Code From http://poshcode.org/624
- ## Create a compilation environment
- $Provider=New-Object Microsoft.CSharp.CSharpCodeProvider
- $Compiler=$Provider.CreateCompiler()
- $Params=New-Object System.CodeDom.Compiler.CompilerParameters
- $Params.GenerateExecutable=$False
- $Params.GenerateInMemory=$True
- $Params.IncludeDebugInformation=$False
- $Params.ReferencedAssemblies.Add("System.DLL") | Out-Null
- $TASource=@'
- namespace Local.ToolkitExtensions.Net.CertificatePolicy{
- public class TrustAll : System.Net.ICertificatePolicy {
- public TrustAll() {
- }
- public bool CheckValidationResult(System.Net.ServicePoint sp,
- System.Security.Cryptography.X509Certificates.X509Certificate cert,
- System.Net.WebRequest req, int problem) {
- return true;
- }
- }
- }
- '@
- $TAResults=$Provider.CompileAssemblyFromSource($Params,$TASource)
- $TAAssembly=$TAResults.CompiledAssembly
- ## We now create an instance of the TrustAll and attach it to the ServicePointManager
- $TrustAll=$TAAssembly.CreateInstance("Local.ToolkitExtensions.Net.CertificatePolicy.TrustAll")
- [System.Net.ServicePointManager]::CertificatePolicy=$TrustAll
- ## end code from http://poshcode.org/624
- ## Set the URL of the CAS (Client Access Server) to use two options are availbe to use Autodiscover to find the CAS URL or Hardcode the CAS to use
- #CAS URL Option 1 Autodiscover
- $service.AutodiscoverUrl($MailboxName,{$true})
- "Using CAS Server : " + $Service.url
- #CAS URL Option 2 Hardcoded
- #$uri=[system.URI] "https://casservername/ews/exchange.asmx"
- #$service.Url = $uri
- ## Optional section for Exchange Impersonation
- #$service.ImpersonatedUserId = new-object Microsoft.Exchange.WebServices.Data.ImpersonatedUserId([Microsoft.Exchange.WebServices.Data.ConnectingIdType]::SmtpAddress, $MailboxName)
- #PropDefs
- $PeopleHubSortGroupPriority = new-object Microsoft.Exchange.WebServices.Data.ExtendedPropertyDefinition([Microsoft.Exchange.WebServices.Data.DefaultExtendedPropertySet]::Common, "PeopleHubSortGroupPriority", [Microsoft.Exchange.WebServices.Data.MapiPropertyType]::Integer);
- $PeopleHubSortGroupPriorityVersion = New-Object Microsoft.Exchange.WebServices.Data.ExtendedPropertyDefinition([Microsoft.Exchange.WebServices.Data.DefaultExtendedPropertySet]::Common, "PeopleHubSortGroupPriorityVersion", [Microsoft.Exchange.WebServices.Data.MapiPropertyType]::Integer);
- # Bind to the Contacts Folder
- $folderid= new-object Microsoft.Exchange.WebServices.Data.FolderId([Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::Contacts,$MailboxName)
- $Contacts = [Microsoft.Exchange.WebServices.Data.Folder]::Bind($service,$folderid)
- $NewFolder = new-object Microsoft.Exchange.WebServices.Data.Folder($service)
- $NewFolder.DisplayName = $NewFolderName
- $NewFolder.FolderClass = "IPF.Contact"
- $NewFolder.SetExtendedProperty($PeopleHubSortGroupPriority,5);
- $NewFolder.SetExtendedProperty($PeopleHubSortGroupPriorityVersion,2);
- $NewFolder.Save($Contacts.Id)
- "Created Folder"