Connect to Office 365 via PowerShell

1. Allowing PowerShell executing scripts: https://headadmin.net/?p=172

2. Do this in an elevated PowerShell promt:
$UserCredential = Get-Credential

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

Import-PSSession $Session

http://technet.microsoft.com/en-us/library/jj984289(v=exchg.150).aspx

Allowing PowerShell executing scripts

By default PowerShell is restricted to not allow script execution. To allow script execution do the following

Open PowerShell in elevated mode (run as administrator) and run the following command:
Set-ExecutionPolicy unrestricted

To verifiy how if script execution is allowed or not run the following command in PoweShell:
Get-ExecutionPolicy