Tuesday, 19 January 2016

How to Connect Exchange Online using remote PowerShell

Exchange Online PowerShell module provides cmdlets to manage Office 365 cloud objects such as mailbox, groups, etc...

#1 Connect to Exchange Online:

#1 Open Windows PowerShell and run the following command and type your Office 365 admin user name and password, and then click OK.
$365Logon = Get-Credential
#2 Run the following command to create new office 365 powershell session.
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $365Logon -Authentication Basic -AllowRedirection
#3 Then, run the following command to import new exchange online powershell session.
Import-PSSession $Session

#2 Use PowerShell Cmdlets with Office 365:

Once you have imported the cloud Exchange powershell module, you can now run the all available cmdlets. Let’s start with simple cmdlet:
The above cmdlet, lists office 365 mailboxes.

#3 Remove Remote PS Session:

Once you have completed all the works with remote office 365 powershell, you have to remove the session using below command
Remove-PSSession $Session
Note : If you are newbie to powershell, don’t forget to set your execution policy to unrestricted or you might get an error when you try run the script. Use the below command to set your execution policy:
Set-ExecutionPolicy RemoteSigned 


No comments:

Post a Comment