As you may have heard, the Office 365 beta has started and it includes Microsoft Exchange Online, which is powered by Exchange Server 2010 SP1, and it can be fully managed via PowerShell v2 remoting. So, if you’re in the Office 365 beta, you can use the steps below to connect to Exchange Online with remote PowerShell from any machine with an internet connection. You just need PowerShell v2, which is installed by default on Windows 7 and 2008 R2. It can be downloaded and installed on down-level operating systems through Windows Update, or from here.

The process is very similar to how you would configure an implicit remoting session to an on-premise Exchange 2010 server. I blogged about how to do this here a while back. To connect to Exchange Online, use the following commands:

$cred = Get-Credential

When you execute the above command, you’ll be prompted for your Office 365 credentials. Enter your username in UPN format, such as user@domain.com. Next, create a new PSSession object using the following syntax:

$s = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell -Credential $cred -Authentication Basic -AllowRedirection

The initial remote endpoint you’ll want to use is at ps.outlook.com as shown above. The -AllowRedirection switch parameter used in this command will allow redirection to the appropriate Exchange server using different URI. You’ll see a warning message in the shell informing you of the new server URI when you execute the above command.

Next, import the cmdlets to your local shell session:

$importresults = Import-PSSession $s

This will create a PSModuleInfo object and import the cmdlets into your local session. At this point, you are ready to start working with the Exchange cmdlets, but if you take a look at the module first, you’ll notice a couple of interesting things:

$importresults.ExportedFunctions.Count

Notice that the function count for this module is only 295. This means that you only have access to a fraction of the cmdlets that you would in an on-premise Exchange 2010 environment. You can run Get-Command as shown below to page through all of the Exchange cmdlets made available through the remote session:

Get-Command -Module $importresults | Out-Host -Paging

You’ll notice as you go through the cmdlets that most of them are recipient specific cmdlets. Since this is a hosted solution, you’ll see that cmdlets like *-MailboxServer, *-ExchangeServer, etc. are not available to you.

So, that’s all there is to it. If you want to learn more about Office 365, check out the Office 365 home page, and keep an eye on the Office 365 blog for news and updates.

Update 5/19/11: Just a quick update about PowerShell execution policy…

From the cmdlet help for Import-PSSession:

To use Import-PSSession, the execution policy in the current session cannot be Restricted or AllSigned, because the module that Import-PSSession creates contains unsigned script files that are prohibited by these policies.

The default PowerShell execution policy on a machine is set to Restricted. You can change the execution policy to RemoteSigned using Set-ExecutionPolicy RemoteSigned to get the above example to work. This actually happens automatically when installing the Exchange 2010 tools on a machine, but if you are importing the cmdlets on a system without the tools, you’ll need to manually set the execution policy to a less restrictive setting (if you have not already done so). See the help file about_Execution_Policies for more details. Thanks to Terence who posted about his experience with this in the comments.