Scripts

Connecting to Office 365 PowerShell

Many time I find myself wanting to connect to Exchange, Skype for Business, and Azure AD all at the same time.  Maybe I have a sheet that has parts from each of those area and I need to connect it all in another sheet.  This post is derived from this page, but simplified, I hope

https://support.office.com/en-us/article/Managing-Office-365-and-Exchange-Online-with-Windows-PowerShell-06a743bb-ceb6-49a9-a61d-db4ffdf54fa6?ui=en-US&rs=en-US&ad=US

To do this, you need Windows 8 or later (or 2012 or later) and .net framework 3.5

And you need to set the PowerShell Execution Policy.  I generally set it to unrestricted, but the minimum is RemoteSigned.  To run this command it must be done in elevated permissions

Set-ExecutionPolicy -ExecutionPolicy Unrestricted

All of this is 64 bit (not sure why you would be using 32bit Windows)
1.Download and install the Microsoft Online Services Sign-in Assistant Module
2.Download and install the Azure Active Directory Module
3.Download and Install the Skype for Business Online Module  Though you don’t really need this all the time, but it helps

Reboot your computer

Open a PowerShell and import the modules you need

Import-Module SkypeOnlineConnector

Import-Module MSOnline

Import-Module MSOnlineExtened

Wait, no Exchange.  That is right, you connect to exchange by importing the module when connected.

Now I setup a dedicated user for online management, something like onlineadmin@domain.onmicrosoft.com.  This way I can always connect even if ADFS or DirSync is broken.

$cred = get-credentials user@domain.com or user@domain.onmicrosoft.com

Connect to office 365

Connect-MsolService -Credential $cred

Connect to Exchange Online

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

Import-PSSession $exsession

Connect to Skype for Business Online

$sfbonline = New-CsOnlineSession -Credential $cred

Import-PSSession $sfbonline –AllowClobber

6 thoughts on “Connecting to Office 365 PowerShell

  1. Prix Du Amoxicillin En Suisse [url=http://cialibuy.com]Buy Cialis[/url] How To Identify Amoxicillin From Mexico Find Macrobid 100mg Bacterial Infections Visa

  2. El Cialis Es Mejor Levitra How Long Does It Last Difference Between Augmentin And Amoxicillin [url=http://allngos.com][/url] Amoxicillin Dairy Animation Du Clomid Buy Propecia Online From Canada

Leave a Reply

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