To connect to Office 365 using PowerShell: Connect to Office 365 using PowerShell
$cred = Get-Credential $session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential $cred -Authentication Basic -AllowRedirection Import-PSSession $session ... your commands here ... Remove-PSSession $session
This method requires the Azure AD PowerShell CMDlets - note the system requirements - will run on Server 2008 R2 and above. Non-R2 version of Server 2008 is NOT supported, the CMDlets will not install. This means it also does not work on SBS 2008.
Do the following from the icon titled “Microsoft Azure Active Directory Module for Windows PowerShell”, I had errors when running it directly from PowerShell.
Import-Module MSOnline Connect-MsolService