I have recently been migrating my work, personal and a few other domains, including clients to a new Microsoft Office 365 tenants. Nothing new to report here, however due to having many rules in place on some of the mailboxes I have needed to update the rules allowance on several of the mailboxes away from the default 64KB to a higher amount (in my case I chose 265KB as this is the maximum allowed). Now this was always a simple task on a locally hosted Exchange, simply done through PowerShell, and it turns out it can still be done this way on Office 365, but with a few more added steps to connect to the PowerShell system on the Office 365 Outlook server.
Firstly you want to open up PowerShell and input the command
$O365Creds = Get-Credential
This tells PowerShell to ask for a credential via the familiar login popup box.
This credential box DOES NOT check the credentials validity, it simply grabs them and puts the in a variable called $O365Creds.
Now we are going to actually connect to the system so we can start doing something
$O365Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential $O365Creds -Authentication Basic –AllowRedirection
That commands opens the session, if you have the wrong credentials you will get an error stating
New-PSSession : [ps.outlook.com] Connecting to remote server ps.outlook.com failed with the following error message :Access is denied.
If this happens simply re-run the credential request command, then re-run the session creation command
Once successful you will connect to the PowerShell server, with this you will most likely get a warning stating the following:
WARNING: Your connection has been redirected to the following URI:
This is due to the “–AllowRedirection” switch in the session creation command. This switch is there to allow a single URL to redirect to multiple PowerShell servers within a cluster and is needed in an Office 365 system is a cluster and there is no way of knowing which PowerShell servers have empty sessions available on them, consequently the above warning is to be expected and not a concern
Both these are shown below;
Now we want to import the remote session (and consequently import the command information) to our local PowerShell session to do this we run, a progress bar will display in PowerShell as this is happening
When doing this you may get an error if you are doing this for the first time, or where the Execution Policy settings changed
Import-Module : There were errors in loading the format data file:
Microsoft.PowerShell, , <<File Path>> cannot be loaded because the execution of scripts is disabled on this system.
To get over this error you need to run an elevated command prompt (you DO NOT have to close the original PowerShell window) and run the following command
PowerShell will give you a warning stating that this may potentially expose your system to security risks, either enter Y (for yes) and hit enter, or simply hit enter (as Y is the default) if you are happy with this
Once this is done re-run the PowerShell import command, it should now succeed
Now we can run the command to increase the amount of space for the rules which is a simple one line command
set-mailbox -identity email@example.com -RulesQuota 256kb
This command expand the rules quote of mailbox firstname.lastname@example.org to 256KB (this is the maximum available)
This command will not show any confirmation it will simply drop to asking you for the next command to input. Input any other rules upgrades (or any other commands you want to run remotely) and then log off
To do this simply run;
This will again show no confirmation and will simply drop you to the next command prompt