PowerShell: Create folders in users’ mailboxes No ratings yet.

Here is a PowerShell EWS script that will create folders (one or more) in users’ mailboxes.  To run it against a single mailbox, syntax is:

.\Create-Folders.ps1 user1.ex2k7@hybrid.local “Folder 1;Folder 2”

By default, folders are created under the inbox.  For multiple folders (as above), separate the folder names with a semicolon.  You can specify the parent folder (in case this isn’t the inbox) by using the -ParentFolder parameter.

The script also supports taking a text file with a list of mailboxes as the input (just replace the mailbox address with the path to the text file).  You can also use it with standard PowerShell scripting.  To process all mailboxes (for example), you could do the following (from an Exchange Management Shell session):

Get-Mailbox | foreach {
           .\Create-Folders.ps1 $_.PrimarySmtpAddress “Private;Archive” -Impersonate
     } catch { }


Note that the try…catch is important in the above, as without it the script would stop at any mailbox that generated an error.

Other than the above, the usual parameters (for most of my EWS scripts) apply to this one: -AuthUsername, -AuthPassword, -AuthDomain, -Impersonate, -EwsUrl, -EwsManagedApiPath, -IgnoreSSLCertificate, -AllowInsecuredRedirection, -WhatIf


Please rate this


1 thought on “PowerShell: Create folders in users’ mailboxes

Leave a Reply

Your email address will not be published. Required fields are marked *