Granting Permissions via PowerShell to ALL Office 365 | Exchange Online Mailboxes

The most powerful way to manage Office 365 is by using PowerShell, which is a command line interface that connects to Office 365 via the Internet. While at first glance it may seem overwhelming to those unfamiliar with working with the Command Line, it really isn’t as hard as it looks. This documentation will guide you through the steps of using PowerShell to grant the DSAdmin365 or equivalent account full permissions to ALL mailboxes within your office 365 environment by taking the actions outlined below.

NOTE: If in the future you add more mailboxes to your Office 365 environment you will need to repeat this process so that the DSAdmin365@yourdomain.com is granted rights to the new mailboxes

Setting up your computer to use PowerShell

If you have not used PowerShell on your computer previously OR if you experience issues when running the PowerShell commands then the first step is to ensure your computer is enabled to use PowerShell by:

  1. Validate that you have .NET Framework Version 4.5.2 or later installed by following the instructions in this link https://msdn.microsoft.com/en-us/library/hh925568%28v=vs.110%29.aspx?f=255&MSPPError=-2147217396

  2. Downloading tools from the Microsoft website using this link http://technet.microsoft.com/en-us/library/jj151815.aspx

Start the PowerShell Command Line Interface (CLI)

You will need to start PowerShell as the Administrator and the easiest way to accomplish that is to do the following

  1. Click on the START or Windows button and type PowerShell

  2. Right click on "Windows PowerShell" and select "Run as administrator"

  3. The PowerShell Window Opens

 

Copying & Pasting Commands into the PowerShell CLI

You can either type commands into the PowerShell CLI or use Copy & Paste which makes things much easier

 

Connecting to your Office 365 Environment

For each of the commands listed below, either type or copy and paste the content that comes after "Command:" into PowerShell, hit ENTER and if present follow any bulleted instructions under each command.

NOTE: if you enter a command incorrectly it will return a verbose error in red.  To clear the error or previous command and result simple type CLS and hit ENTER

Command: Set-ExecutionPolicy RemoteSigned

Command: $session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "https://outlook.office365.com/powershell-liveid/" -Credential $cred -Authentication Basic -AllowRedirection

NOTE: if the credentials are accepted the CLI will do line return, however if the credentials are refused/incorrect it will return a verbose error in red

Command: Import-PSSession $Session

NOTE: The above command imports the office365 commands into PowerShell similar to launching a PowerShell for Exchange

Granting Full Permissions for ALL mailboxes to the DSAdmin365@YourDomain.com account

Command: Get-Mailbox -ResultSize unlimited | Add-MailboxPermission -User DSAdmin365@yourdomain.com -AccessRights FullAccess -InheritanceType all

NOTE: If in the future you add more mailboxes to your Office 365 environment you will need to repeat this process so that the DSAdmin365@yourdomain.com is granted rights to the new mailboxes


Return to Method 2: Grant Permissions to All Office 365 | Exchange Online Mailboxes via PowerShell