quarta-feira, 28 de outubro de 2015

Connect to Office 365 Cloud Services using PowerShell

You can use the following versions of Windows:
  • Windows 8 or Windows 8.1
  • Windows Server 2012 or Windows Server 2012 R2
  • Windows 7 Service Pack 1 (SP1)*
  • Windows Server 2008 R2 SP1*
* You need to install the Microsoft .NET Framework 4.5 or 4.5.1 and then either the Windows Management Framework 3.0 or the Windows Management Framework 4.0. For more information, see Installing the .NET Framework 4.5, 4.5.1 and Windows Management Framework 3.0 or Windows Management Framework 4.0.

You need to install the modules that are required for Office 365, SharePoint Online, and Skype for Business Online:

  • Microsoft Online Service Sign-in Assistant for IT Professionals RTW
  • Windows Azure Active Directory Module for Windows PowerShell (64-bit version)
  • SharePoint Online Management Shell
  • Windows PowerShell Module for Lync Online (Skype for Business Online)


Connect to Exchange Online

On your local computer, open Windows PowerShell and run the following command.

  • $UserCredential = Get-Credential

In the Windows PowerShell Credential Request dialog box, type your Exchange Online user name and password, and then click OK.


  • Run the following command.


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


Run the following command.



  • Import-PSSession $Session


If you get and error like "Import-PSSession : Files cannot be loaded because running scripts is disabled on this system. P", run this: 



  • Set-ExecutionPolicy Unrestricted
and then again: 

  • Import-PSSession $Session
When done: Remove-PSSession $Session to clear the session

Sem comentários: