Monday, 8 December 2014

Connecting Power shell to Office365

The most powerful way to manage Office 365 is by using PowerShell, a command line interface that connects to Office 365 via the Internet.

Start the Powershell command line

Now that you have the tools installed, you can go ahead and open Powershell. The easiest way to do this is to press the start button and simply typepowershell
You will now see a Powershell window, and the fun can begin!

Using Powershell

Now that you have a Powershell Window open, you can connect to Microsoft Office 365.
Firstly, you need to create a connection to Office 365. You can do this by typing (or copying/pasting) the following into Powershell.

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

Once this is in the Powershell window, press Enter to execute the command.


Now you simply type in the username and password for an Administrator account in your Office 365 and click OK.
You will probably see some warnings.  Don’t worry, they are normal.
You are now authenticated into Office 365. The last step is to connect up to Office 365 by using the following Powershell command:
Import-PSSession $session


Congratulations! You’re connected!
Now you’ve gone to all the trouble of connecting to Powershell, let’s do something to prove that it works. Type the following into the Powershell window and press Enter:
get-mailbox
You should now see a list of all the users in your Office 365 account that have mailboxes!

No comments:

Post a Comment

SharePoint tenant opt-out for modern lists is retiring in 2019

We're making some changes to how environments can opt out of modern lists in SharePoint. Starting April 1, 2019, we're going to be...