I need to create a some folders in every single mailbox in our exchange organisation.
Is there a quick way to achieve this with a powershell script?
(note this is not public folders, these folders must exist inside the users mailbox)
I need to create a some folders in every single mailbox in our exchange organisation.
Is there a quick way to achieve this with a powershell script?
(note this is not public folders, these folders must exist inside the users mailbox)
You can do this with the Exchange Web Services (EWS) API. This script should create a folder in a mailbox (I don't have an E2K10 machine w/ EWS 1.1 installed handy right now so I'm cobbling this together from code samples and memory and hoping it'll actually work-- it looks right). This should work as the basis for a script to iterate through mailboxes creating folders (but since I'm such a PowerShell dunce I'm leaving that up to you):
$MailboxName = "mailbox@domain.com"
$dllpath = "C:\Program Files\Microsoft\Exchange\Web Services\1.0\Microsoft.Exchange.WebServices.dll"
[void][Reflection.Assembly]::LoadFile($dllpath)
$service = New-Object Microsoft.Exchange.WebServices.Data.ExchangeService([Microsoft.Exchange.WebServices.Data.ExchangeVersion]::Exchange2007_SP1)
$windowsIdentity = [System.Security.Principal.WindowsIdentity]::GetCurrent()
$sidbind = "LDAP://<SID=" + $windowsIdentity.user.Value.ToString() + ">"
$aceuser = [ADSI]$sidbind
$service.AutodiscoverUrl($aceuser.mail.ToString())
$folderid = new-object Microsoft.Exchange.WebServices.Data.FolderId([Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::Root, $MailboxName)
$RootFolder = [Microsoft.Exchange.WebServices.Data.Folder]::Bind($service, $folderid)
$NewFolder = new-object Microsoft.Exchange.WebServices.Data.Folder($service)
$NewFolder.DisplayName = "Folder_to_Create"
$NewFolder.Save($RootFolder.Id.UniqueId)
This script assumes you've got EWS 1.1 installed and are logged-on with a credential that has permission to access the subject mailbox.