Here is a PowerShell EWS script that will create folders (one or more) in users’ mailboxes.  It requires the EWS Managed API to be installed, and if it is to be run against multiple mailboxes then the relevant permissions will need to be granted to the mailboxes (e.g. ApplicationImpersonation).

Example 1

.\Create-MailboxFolder.ps1 -RequiredFolders "Folder 1;Folder 2"
 This will create the folders Folder 1 and Folder 2 in the current user's mailbox.  The folders are created under the Inbox folder.

Example 2

.\Create-MailboxFolder.ps1 -Mailbox "c:\mailboxes.txt" -RequiredFolders "Folder 1;Folder 2" -ParentFolder "\My Folder" -Impersonate
 This will create Folder 1 and Folder 2 within folder \My Folder (this folder must already exist in the users' mailboxes).  The mailboxes in which the folders are created are listed in the text file c:\mailboxes.txt.

Example 3

.\Create-MailboxFolder.ps1 -Credentials (Get-Credential-Mailbox "c:\mailboxes.txt" -RequiredFolders "Folder 1;Folder 2" -ParentFolder "\My Folder" -Impersonate
 This is the same as example 2, except you will be prompted for credentials that will then be used to connect to Exchange.

Example 4

.\Create-MailboxFolder.ps1 -Credentials (Get-Credential-Mailbox "c:\mailboxes.txt" -RequiredFolders "Folder 1;Folder 2" -ParentFolder "WellKnownFolderName.SentItems" -Impersonate -EwsUrl ""
   This will create Folder 1 and Folder 2 in the Sent Items folder (regardless of the locale of the mailbox).  The mailboxes in which the folders are created are listed in the text file c:\mailboxes.txt.  The EWS Url is specified here for Office 365 (which saves the script having to do autodiscover), and you will be prompted for credentials when the script is run (i.e. will need to enter valid credentials for Office 365).


-Mailbox If present, this is the SMTP address of the mailbox that will be accessed OR it is a path to a text file that contains a list of SMTP addresses (in which case the script will attempt to access all mailboxes in the list).  If missing, then the script will try to determine the current user's email address and use that.
-RequiredFolders The list of folders to be created (if more than one, separate with a semi-colon e.g. "Folder 1;Folder 2"
-ParentFolder If specified, this is the folder in which the required folders will be created.  If this parameter is missing, the Inbox folder is used.  You can either specify a full path (e.g. "\My Folder") or use the WellKnownFolderName enumeration (the advantage of this is that it won't matter what locale the mailbox is using).
-FolderClass When specified, the default item type of the folder will be set to this.  If not specified, the default item type is "IPF.Note"
-Archive When specified, the mailbox archive is accessed (instead of the main mailbox).
-Credentials Will accept PSCredentials for authentication to Exchange (e.g. Get-Credential).  This cannot be used with other authentication parameters (e.g. -username).
-Username Username to authenticate with Exchange.
-Password Password to authenticate with Exchange.
-Domain Domain for authentication.
-Impersonate Mailbox will be accessed using Impersonation (the authenticating account needs impersonation rights to the mailbox).
-EwsUrl The EWS endpoint.  If not specified, autodiscover will be used to determine the correct EWS URL.  For Office 365, you can use "" as the URL.
-EwsManagedApiPath The path to the EWS Managed API.  The script will search standard locations for the dll, but if you have installed it elsewhere you may need to specify the location.
-IgnoreSSLCertificate If present, any SSL certificate errors will be ignored.  Useful for testing in a lab with self-signed certificates.
-AllowInsecureRedirection If present, autodiscover will accept redirects to insecure addresses.
-WhatIf If present, no changes will be written to the mailbox.
-LogFile If specified, actions will be logged to this file (the same information is shown in the console).
-TraceFile If specified, EWS requests/responses will be logged to this file.  This is only useful for debugging.