{"id":2940,"date":"2019-01-15T09:13:31","date_gmt":"2019-01-15T07:13:31","guid":{"rendered":"https:\/\/msb365.abstergo.ch\/?p=2940"},"modified":"2019-01-15T09:13:31","modified_gmt":"2019-01-15T07:13:31","slug":"managing-shared-mailboxes-using-powershell","status":"publish","type":"post","link":"https:\/\/www.msb365.blog\/?p=2940","title":{"rendered":"Managing shared Mailboxes using PowerShell"},"content":{"rendered":"<p>I just had to do some additional work in a project we have just finished. One of the main tasks has been adjusting some permissions for shared mailboxes.<\/p>\n<p>In this article, I wrote down some usefull PowerShell commands for managing shared mailboxes.<\/p>\n<p>&nbsp;<\/p>\n<h2><strong>What is a shared mailbox?<\/strong><\/h2>\n<p>A shared mailbox is a type of user mailbox that doesn&#8217;t have its own user name and password. As a result, users can&#8217;t log into them directly. To access a shared mailbox, users must first be granted Send As or Full Access permissions to the mailbox. Once that&#8217;s done, users sign into their own mailboxes and then access the shared mailbox by adding it to their Outlook profile. In Exchange 2003 and earlier, shared mailboxes were just a regular mailbox to which an administrator could grant delegate access.<\/p>\n<p>&nbsp;<\/p>\n<p>To a shared mailbox we can assign the following permissions:<\/p>\n<ul>\n<li><strong>Send As:<\/strong> The Send As permission lets a user impersonate the shared mailbox when sending mail. For example, if Desmond logs into the shared mailbox Marketing Department and sends an email, it will look like the Marketing Department sent the email.<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul>\n<li><strong>Full Access:<\/strong> The Full Access permission lets a user log into the shared mailbox and act as the owner of that mailbox. While logged in, the user can create calendar items; read, view, delete, and change email messages; create tasks and calendar contacts. However, a user with Full Access permission can&#8217;t send email from the shared mailbox unless they also have Send As or Send on Behalf permission.<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul>\n<li><strong>Send on Behalf:<\/strong> The Send on Behalf permission lets a user send email on behalf of the shared mailbox. For example, if Desmond logs into the shared mailbox Software development and sends an email, it look like the mail was sent by &#8220;Desmond on behalf of Software development&#8221;. We can&#8217;t use the EAC to grant Send on Behalf permissions, we must use Set-Mailbox cmdlet with the GrantSendonBehalf parameter.<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<h2><strong>Creating shared mailboxes<\/strong><\/h2>\n<p>Creating a shared mailbox is similar as creating any other type of mailbox in the Exchange management shell. The point we need to think about is to specify the type of the Mailbox. That means that the command could look like this:<\/p>\n<pre class=\"\">New-Mailbox \u2013Name \u2018Software development\u2019 \u2013Shared<\/pre>\n<p>&nbsp;<\/p>\n<p>The first example showed us, how to create a simple shared Mailbox. However, normally this is not enough and we need to provide more information. One thing is to define an Alias and an smtp address. This we can do with the following command:<\/p>\n<pre class=\"\">New-Mailbox \u2013Name \u2018Software development\u2019 \u2013alias development \u2013Shared \u2013PrimarySmtpAddress <a href=\"mailto:dev@contoso.com\">dev@contoso.com<\/a><\/pre>\n<p>&nbsp;<\/p>\n<h2><strong>Managing permissions<\/strong><\/h2>\n<p>As I have written in the beginning of this article, a shared mailbox is a mailbox without its own user and password. To be able to use a shared mailbox, we need to assign permissions to users. In this chapter we will learn, how to do that using PowerShell.<\/p>\n<p>If we continue with the shared mailbox we have created in the previous chapter, Software development, we want to assign full access to the user Desmond. This can be done by using the following command:<\/p>\n<pre class=\"\">Add-MailboxPermission \u2018Software development\u2019 \u2013User Desmond \u2013AccessRights FullAccess \u2013InheritanceType all<\/pre>\n<p>&nbsp;<\/p>\n<p>If our Exchange has still the default configuration, the Mailbox \u201cSoftware development\u201d will be auto mapped to the User Desmond.<\/p>\n<p>However, sometimes we want to prevent that a shared mailbox will be auto mapped to a user with full access permissions. In this case, we need to add the following parameter to our command: <em>-AutoMapping $False<\/em>. In this case, the command will look like this:<\/p>\n<pre class=\"\">Add-MailboxPermission \u2018Software development\u2019 \u2013User Desmond \u2013AccessRights FullAccess \u2013InheritanceType all \u2013AutoMapping $False<\/pre>\n<p>&nbsp;<\/p>\n<p><strong>Note<\/strong>: When we assign \u201cFull Access\u201d permission to a Group, the AutoMap feature is not \u201cactivated\u201d because, the Full Access permission granted to \u201cGroup Object,\u201d and not for the \u201cUser object\u201d (the group members).<\/p>\n<p>In this case, we will need to instruct each of the group members how to add the \u201cadditional Mailbox\u201d manually for the Exchange mailbox, which they have \u201cFull access\u201d permission.<\/p>\n<p>To avoid this default behaviour, we can use a \u201clittle trick,\u201d by using a PowerShell command.<\/p>\n<p>The PowerShell command will \u201cextract\u201d group members to a \u201cuser list\u201d and in the next step assigns the Full Access permission separately, for each user (each of the Group members).<\/p>\n<p>The command for that will look like this:<\/p>\n<pre class=\"\">$DL = Get-DistributionGroupMember \u201cdevelopment Department\u201d | Select-Object \u2013ExpandProperty Name ForEach ($Member in $DL) {Add-MailboxPermission \u2013Identity \u2018Software development\u2019 \u2013User $Member \u2013AccessRights \u2018FullAccess\u2019 \u2013InheritanceType All}<\/pre>\n<p>&nbsp;<\/p>\n<p>We also can add SendAs or Send on Behalf permissions using Powershell. If we want to do that for a single mailbox, we can do it with the following example:<\/p>\n<pre class=\"\">Add-RecipientPermission \u2018development Department\u2019 \u2013Trustee Desmond \u2013AccessRights SendAs \u2013confirm:$false<\/pre>\n<p>&nbsp;<\/p>\n<p>Of course, we also can set the SendAs permission for Desmond to all of our shared mailboxes. To do that, we need the following command:<\/p>\n<pre class=\"\">Get-Mailbox \u2013Filter \u2018(RecipientTypeDetails \u2013eq \u201cSharedMailbox\u201d)\u2019 | Add-RecipientPermission \u2013Trustee Desmond \u2013AccessRights SendAs \u2013confirm:$False<\/pre>\n<p>&nbsp;<\/p>\n<h3><strong>Shared Mailbox Calendar permission<\/strong><\/h3>\n<p>We also can assign dedicated permission to a calendar of a shared mailbox. To be able to do that, we need the specific syntax of the calendar folder.<\/p>\n<p><strong>Note<\/strong>: by working with this syntax, we need to know about the shared mailbox language. If the shared mailbox is set-up in English the syntax will be \u2018calendar\u2019, if it is configured in German as example, the syntax will be calendar. To add dedicated permissions to a calendar of a shared mailbox to Desmond, we need to use the following command:<\/p>\n<pre class=\"\">$MailboxCalendar = \u201cdevelopment\u201d:\\calendar\r\nAdd-MailboxFolderPermission \u2013Identity $MailboxCalendar \u2013AccessRight PublishingEditor \u2013User Desmond<\/pre>\n<p>&nbsp;<\/p>\n<p>As we can see in the last command, we need now to define different permissions called AccessRights. If you need to know, which AccessRights can be set for configuring the FolderPermissions, you can follow the Microsoft Link <a href=\"https:\/\/docs.microsoft.com\/en-us\/powershell\/module\/exchange\/mailboxes\/add-mailboxfolderpermission?view=exchange-ps\" target=\"_blank\" rel=\"noopener\"><strong>HERE&nbsp;<\/strong><\/a><\/p>\n<p>&nbsp;<\/p>\n<h2><strong>Display various types of Mailbox permissions<\/strong><\/h2>\n<p>The default output of the PowerShell cmdlet Get-MailboxPermission that we use for view Mailbox permissions and the PowerShell cmdlet Get-RecipientPermission that we use for view SEND AS permissions, displays redundant information, that makes it difficult to understand the information about the Exchange mailbox permissions clearly.<\/p>\n<p>For this reason, we add \u201cfilter\u201d that removes that redundant information.<\/p>\n<p>&nbsp;<\/p>\n<p>Displaying FullAccess permissions for shared mailboxes:<\/p>\n<pre class=\"\">Get-MailboxPermission \u201cdevelopment Department\u201d | Where-Object { ($_.IsInherited -eq $False) -and -not ($_.User -like \u201cNT AUTHORITY\\SELF\u201d) } | Select-Object Identity, user, AccessRights<\/pre>\n<p>&nbsp;<\/p>\n<p>Displaying SendAs permissions for shared mailboxes:<\/p>\n<pre class=\"\">Get-RecipientPermission \u201cdevelopment Department\u201d | Where-Object {($_.IsInherited -eq $False) -and -not ($_.Trustee -like \u201cNT AUTHORITY\\SELF\u201d) } | Select-Object Trustee, AccessRights<\/pre>\n<p>&nbsp;<\/p>\n<p>Displaying Calendar permissions for shared mailboxes:<\/p>\n<pre class=\"\">$MailBoxCalendar = \u201cdevelopment Department\u201d:\\calendar\r\nGet-MailboxFolderPermission $MailBoxCalendar | Select-Object FolderName, user, AccessRights<\/pre>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h2><strong>Converting Mailboxes<\/strong><\/h2>\n<p>Microsoft Exchange allows us to convert our mailboxes into different types between shared mailboxes, resource mailboxes and regular user mailboxes. However, if we have a look on Exchange online at this moment, we need for each user mailbox an Exchange online license. However, by using shared mailboxes an Exchange online license is not needed. If we want to convert a regular user Mailbox to a shared mailbox, we can run the following command:<\/p>\n<pre class=\"\">Set-Mailbox Desmond \u2013Type shared<\/pre>\n<p>&nbsp;<\/p>\n<p>And if we want to go the opposed way, we just need to change the <em>\u2013Type<\/em> parameter:<\/p>\n<pre class=\"\">Set-Mailbox Desmond \u2013Type Regular<\/pre>\n<p>&nbsp;<\/p>\n<h2><strong>Configuring Mailbox size<\/strong><\/h2>\n<p>By default every mailbox uses the parameter of the Mailbox Database where the Mailbox was created. However, by using PowerShell we are able to overrule this setting:<\/p>\n<pre class=\"\">Set-Mailbox \u201cdevelopment Department\u201d -ProhibitSendReceiveQuota 50GB -ProhibitSendQuota 49.7GB -IssueWarningQuota 49.5GB<\/pre>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>Photo by&nbsp;<a href=\"https:\/\/unsplash.com\/photos\/u9wL9bqwRVc?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText\">Kasya Shahovskaya<\/a>&nbsp;on&nbsp;<a href=\"https:\/\/unsplash.com\/search\/photos\/easy-shell?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText\">Unsplash<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I just had to do some additional work in a project we have just finished. One of the main tasks has been adjusting some permissions for shared mailboxes. In this article, I wrote down some usefull PowerShell commands for managing shared mailboxes. &nbsp; What is a shared mailbox? A shared mailbox is a type of [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":2942,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"footnotes":""},"categories":[2,3],"tags":[],"class_list":["post-2940","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-exchange","category-powershell"],"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/www.msb365.blog\/index.php?rest_route=\/wp\/v2\/posts\/2940","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.msb365.blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.msb365.blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.msb365.blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.msb365.blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2940"}],"version-history":[{"count":5,"href":"https:\/\/www.msb365.blog\/index.php?rest_route=\/wp\/v2\/posts\/2940\/revisions"}],"predecessor-version":[{"id":3084,"href":"https:\/\/www.msb365.blog\/index.php?rest_route=\/wp\/v2\/posts\/2940\/revisions\/3084"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.msb365.blog\/index.php?rest_route=\/wp\/v2\/media\/2942"}],"wp:attachment":[{"href":"https:\/\/www.msb365.blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2940"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.msb365.blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2940"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.msb365.blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2940"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}