Microsoft has announced the long-awaited (at least for me) possibility to use PowerShell to do Remote Connection to Exchange Online Protection.
I have previously blogged about doing Remote PowerShell session into Office 365 services, such as my post: How to Remote PowerShell into Exchange Online (Office 365).
Remote PowerShell is great administrative interface since it enables you to manage your Microsoft Exchange Online Protection (EOP) settings directly from PowerShell.
Examples of use could be:
- Setup and configure Connectors
- Configure Transport rules
- Add Accepted domains
How to Connect to Exchange Online Protection
You don’t need Office 365 MS Online PowerShell module for managing your Exchange Online Protection configuration with PowerShell. Just start a PowerShell session and type in following commands:
1 $Cred = Get-Credential
The above command prompts you, for your Office 365 (EOP) tenant admin credentials, it is important to enter as UPN format, such as e.g. admin@contoso.onmicrosoft.com.
Next, we will create a new remote PowerShell session using the following cmdlet:
1 |
<strong><span style="font-size: small;">$s = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.protection.outlook.com/powershell-liveid/ -Credential $cred -Authentication Basic -AllowRedirection</span></strong> |
Next, import the EOP cmdlets into your local PowerShell session, using the following command:
1 Import-PSSession $s
You are now connected to Exchange Online Protection (EOP) with you Office 365 (EOP) Tenant admin and can use Exchange Online Protection PowerShell cmdlets available.
For information about Exchange Online PowerShell cmdlets available see Reference to Available PowerShell Cmdlets in Exchange Online Protection on Technet.
To remove the PowerShell session again, run the following command:
1 Remove-PSSession $s
Remember to remove the session, when you are done.
No Comments
Is giving me this error:
New-PSSession : [outlook.com] Failed to connect to remote server outlook.com
with the following error message: The WinRM client received a status code of 301 from HTTP from remote WS-Management service. For more information, go to the help topic about_Remote_Troubleshooting.
In C:Office 365LogonEOP.ps1:42 caractere:12
+ $Session = New-PSSession -ConfigurationName Microsoft.Exchange
-ConnectionUri ht …
Just tested myself and get the same error.
Seems to be an error on the other end, with Office 365.
Guess we’ll have to wait and see if this gets fixed. 🙂
Thanks! I was thinking it was a problem only with my network.
Nothing yet… is there an e-mail or forum that we could alert Microsoft about this problem?
Found out that the link is wrong.
The correct one is:
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid -Credential $LiveCred -Authentication Basic -AllowRedirection