Share via


Followup to configuring mailboxes via Powershell

I mentioned at the end of the post about configuring a resource mailbox via Powershell that I thought it would be easy to create a one-liner to both create a new mailbox and configure the resource mailbox settings.

In fact, it is very easy, though it did take a bit of time to figure it out.  At first, I was trying to pipe the new-mailbox cmdlet to the set-mailboxcalendarsettings cmdlet, but that didn't work.  After checking with a few folks, I found that what needs to be done here is to encapsulate the new-mailbox cmdlet within the set-mailboxcalendarsettings cmdlet.  When you do this, the encapsulated cmdlet is called and completed, and then the original cmdlet is run.  In the example below, I am creating a new mailbox called Conference Room B.  Again, as I mentioned in the previous post, as long as you designate the mailbox as a resource mailbox, a disabled user account is created, and a password is not required.  If a disabled account is not created, then you will be prompted for a password.  Encapsulation of a cmdlet is done by placing the cmdlet within parentheses.

set-mailboxcalendarsettings (New-Mailbox -UserPrincipalName confb@domain.com -alias confb -name ConferenceRoomB -database "server\database name" -OrganizationalUnit Users -Room:$True -DisplayName "Conference Room B") -automateprocessing:AutoAccept