Pages

Saturday, 25 January 2014

Office365: How to connect to from Powershell

How to connect to the blue, M$ cloud?I suppose you may know how, but this could be little tricky so...What you'll need?I start with that what do you NOT need :) If you manage hybrid environment you may ask yourself and me if you need domain added computer to connect to Office365. No, you don't. You can use any computer you have that will be able to run this:Windows Azure Module for Active DirectoryYou can download it as a part of big package - Web Platform Installerhttp://go.microsoft.com/fwlink/?LinkId=255386ORYou can download it's parts:1. Beuatiful named MOS SIA (Microsoft Online Services Sign-In Assistant) package to work with in Office 365:http://www.microsoft.com/en-us/download/details.aspx?id=392672. Windows Azure ModuleFor x64: http://go.microsoft.com/fwlink/p/?linkid=236297For x86: http://go.microsoft.com/fwlink/p/?linkid=236298Then install - first MOS SIA, then Windows Azure module.After that you should end up with blue window like this:You then could use below commands to connect to your Office365 server:$cred=Get-CredentialAfter that you get window prompt for credentialUse credential in format user@domain$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential $cred -Authentication Basic -AllowRedirectionYou should have info about redirection:WARNING: Your connection has been redirected to the following URI:"https://podXXXXXpsh.outlook.com/powershell-liveid?PSVersion=4.0 "This is OK.Type:Import-PSSession $Session and wait...You should see loading banner:Don't go mad, this could take some time, even few minutes, despite of network and service condition.OK, sometimes it's good not to wait until death, and press Enter (once is enough, really :).After you see all the supported and imported commands, you are ready to manage Office365 from the Powershell.Enjoy!

And...After you end your work with Office365 use the:Remove-PSSession $Session