Tag: Office 365 PowerShell

office365 powershell

Office 365 – How to connect with Powershell

In Office 365 you can do and automate a lot with Windows Powershell. Now this small post shows you how you can connect to Office 365 with Powershell.

  1. Install the Microsoft Online Services Sign-In Assistant
    32-bit
    64-bit
  2. Install the Microsoft Online Services Module for Windows PowerShell
    32-bit
    64-bit
  3. Open Powershell and import the MsOnline Module or use the desktop shortcut which was created by the installer.
    Import-Module MsOnline
  4. Connect to your Microsoft Office 365 account
    Connect-MsolService

    Use your Office 365 LiveID to login (for example [email protected])

  5. Now you can start working with Windows Powershell in your Office 365 account, if you need some more help about the available Powershell cmdlets you can list them with
    Get-Command -Module MsOnline


Powershell: How to connect to Office 365 with Powershell

Powershell Header

You can simply manage and administrate Office 365 from your Powershell prompt or with your own Powershell scripts.

office365

Here is how you can connect to Office 365 with Windows PowerShell:

First create a object with your Windows Live Credentials. This command will open a Windows in which you can enter your Windows Live Credentials for your Office365 Accout. In my case [email protected] and my password.

$LiveCred = Get-Credential

You can open a new Session:

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

Now join the session with:

Import-PSSession $Session

To close the Session:

Remove-PSSession $Session

Now if you join the PS session with Enter-PSSession you can now work online and run commands like Get-User. More about working with Powershell and Office 365 in the next posts.