, ,

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.

5 responses

  1. Björn Avatar
    Björn

    Hallo,

    ich versuche im Moment meinen Exchange Online Account einzurichten, verzweifel aber am Verbindungsaufbau zu den Microsoft Online Services.
    Mit welchen Zugangsdaten muss ich mich da einloggen? Mit den Daten des Administrators von Exchange Online oder einer LiveID oder …?

    1. Thomas Maurer Avatar

      Also bie portal.onmicrosoft.com oder auch mit Powershell brauchst du die neue Windows Live ID in meinem fall beispielsweise: [email protected]

  2. ijaved Avatar

    Thank you. Was looking for one.. I’m using onmicrosoft 365 and ran into issue when I maxed out the powershell connections. I now close the session after I am done. :)

  3. Martin Berger Avatar
    Martin Berger

    Hi. Danke für die Anleitung.
    Ich möchte gerne die Kennwortrichtlinie Deaktivieren. Leider bekomme ich beim connect-MsolService CMDlet immer eine Fehlermeldung.

    Hast du einen Ahnung was da los sein kann?

    MFG,
    Martin

    1. Thomas Maurer Avatar

      Hmmm So auf die Schnelle habe ich keine Idee

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.