Office 365: quick slip into the management console

“How can I quickly logon to Exchange Online powershell?”

If your usual workday implies administering Office 365 organization, or even several ones, – I bet you were looking for automating administration routine procedures. So am I, consulting a number of customers with the Office 365 subscriptions each.

Despite the pretty good Office 365 Admin Portal, many more tasks require or could be done quicker and easier with Powershell. Let’s see what can we automate here:

At first: It’s a good idea to install Windows Azure Powershell module right to your admin workstation:
Prerequisites are:

Now you have a powershell module for Windows Azure Active Directory, which lets you to administer your Office 365 and Exchange Online.
Run it as Administrator to allow script execution:

Set-ExecutionPolicy -ExecutionPolicy unrestricted

This is to be done just once, you don’t need it further unless once you intentionally change -ExecutionPolicy back to Restricted or Default

Usually connecting to Office 365 Active Directory is like this:

$creds = Credential
Connect-MsolService -Credential $creds

Binding your administrators security credentials to a called variable will let you use it again with other connections: e.g. to the Exchange Online –

$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "" -Credential $creds -Authentication Basic -AllowRedirection
Import-PSSession $Session

(copying this code text will show you there are only 2 lines)

That’s enough to have Exchange Management Shell access to your both Exchange Online and Azure AD.

Entering security credentials like this once a day or a week is ok and secure enough. But if you need it several times a day or you have several different credentials for different tenants, you might want to save those security credentials into a PS script. Take into consideration that saving your passwords to text script is a potential security leak if you lose the file or it’s stolen from you. You just make sure to keep those saved credentials in a safe place out of unauthorized access.

So the entire automated entrance to the Office 365 EMS look like this (6 lines):

$User = ""
$PWord = ConvertTo-SecureString –String "yourPasswordGoesHere" –AsPlainText -Force
$Creds = New-Object –TypeName System.Management.Automation.PSCredential –ArgumentList $User, $PWord
Connect-MsolService -Credential $Creds
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "" -Credential $creds -Authentication Basic -AllowRedirection
Import-PSSession $Session

Save this all to a file named like “Welcome.ps1” and keep in a secured place. Now you can simply push this PS1 from your Windows Azure PowerShell and get in within a few seconds.

5 thoughts on “Office 365: quick slip into the management console”

  1. I do trust all of the ideas you’ve introduced in your post. They are very convincing and will definitely work. Still, the posts are very quick for newbies. Could you please prolong them a bit from next time? Thank you for the post.

  2. Hello there, I discovered your website by the use of Google while looking for a related matter, your site got here up, it appears great. I have bookmarked to favourites|added to bookmarks.

  3. Thank you for any other fantastic post. The place else may
    just anyone get that kind of information in such an ideal manner of writing?
    I have a presentation subsequent week, and I am on the look for such information.

  4. This is very interesting, You’re a very skilled blogger. I’ve joined your feed and look
    forward to seeking more of your magnificent post. Also,
    I’ve shared your web site in my social networks!

Leave a Reply

Your email address will not be published.