Connecting to Office365 with PowerShell

The Microsoft Online Services Sign-In Assistant 7.0 is a prerequisite for installing the Microsoft Online Services Module for Windows PowerShell. Use the links below to download the installer.

Once you have the Microsoft Online Services Sign-In Assistant 7.0 installed, now you can install the PowerShell Module. Use the links below to install.

Once you have those two pieces installed, open Windows Azure AD Module for PowerShell as an administrator.

Enter the following commands

$cred = Get-Credential

(Enter Credentials)

Connect-MsolService -credential $cred

 

If you are looking to connect to Exchange Online use the following process.

$Cred = Get-Credential

(Enter Credentials)

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

Import-PSSession $Session

 

When completed, use the following command to close the connection to Exchange Online.

Remove-PSSession $Session

 

Thanks for visiting and reading my posts. I am always looking for more ideas. Please comment or email me with what you would like to see.

Kelsey Epps Office365 MVP

Technical Consultant

Concepps Group

Email Me Follow me on Twitter Connect with me on LinkedIN

 

5 thoughts on “Connecting to Office365 with PowerShell

  1. Pingback: Setting up the Primary AD FS 3.0 Server in Windows Azure for Office365 Single Sign-On | Office 365 Technical Support Blog

  2. Pingback: List and Export the Admin Roles Assigned to Users in Office 365 with PowerShell | Office 365 Technical Support Blog

  3. Seán Deasy

    Hi Kelsey, I’m running into the same problem across a number of devices (logged in with Admin, in each case). The OS Services Sign-In Assistant is downloaded (and showing as such in ‘All Programs’), re-start complete etc., but the Powershell module won’t download, stating it can’t until the Assistant is downloaded. Can you advise please?

    Reply
    1. Seán Deasy

      Hi Kelsey, thanks for getting back to me on this, much appreciated. I have checked this on each install and can confirm I am installing the correct version. I have tried across a number of devices, 2 x Windows 8.1 and a Windows 10. (On reading the minimum system requirements however, I understand Win10 may not yet be supported.) The error is the same in each case – (seemingly!) install the ‘Assistant’ correctly, but it is not ‘seen’ by the PowerShell Module.

      Reply
  4. Seán Deasy

    Hi Kelsey, thanks for getting back to me on this, much appreciated. I have checked this on each install and can confirm I am installing the correct version. I have tried across a number of devices, 2 x Windows 8.1 and a Windows 10. (On reading the minimum system requirements however, I understand Win10 may not yet be supported.) The error is the same in each case – (seemingly!) install the ‘Assistant’ correctly, but it is not ‘seen’ by the PowerShell Module.

    Reply

Leave a Reply