Connect to Exchange Online PowerShell
Exchange Online PowerShell Modunle
You need install Exchange Online module only once. In the next time, run to connect to Exchange Online PowerShell.
##Connect to Exchange Online.
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine -Force;
Install-PackageProvider -Name NuGet -Force;
Set-PSRepository -Name "PSGallery" -InstallationPolicy Trusted;
Install-Module -Name ExchangeOnlineManagement; Install-Module -Name MSOnline;
Import-Module ExchangeOnlineManagement;
Connect-MsolService;
Connect-ExchangeOnline -ShowProgress $true;
Convert to shared mailbox and assign permission
$usermailbox = read-Host 'Users mailbox to convert to shared mailbox';
$supervisor = read-Host 'User who is going to be having access to shared mailbox';
Set-Mailbox $usermailbox -Type shared;
##I've seen Microsoft be a bit slow when doing this, so I've added
##the start sleep command. Feel free to adjust this according to your needs.
start-sleep -s 90
Add-MailboxPermission -Identity $usermailbox -User $supervisor -AccessRights FullAccess;
##End
Remove licenses of the user
(get-MsolUser -UserPrincipalName $usermailbox).licenses.AccountSkuId |
foreach{ Set-MsolUserLicense -UserPrincipalName $usermailbox -RemoveLicenses $_}
5/5 - (1 vote)