0

Connect Windows Powershell to Office 365

By Michael Alfaro on September 5, 2011
Facebook0Twitter1LinkedIn1Google+0

Found the need for this today as we’re switching over to Office 365 and I had to use the power shell to create a Shared Mailbox that multiple people can access.  Step 1 was connecting the powershell to Office 365 as show below.

“Connect Windows PowerShell on your local computer to the cloud-based service

  1. Click Start > All Programs > Accessories > Windows PowerShell > Windows PowerShell.
  2. Run the following command:

    $LiveCred = Get-Credential
  3. In the Windows PowerShell Credential Request window that opens, type the credentials of an account in your cloud-based organization. When you are finished, click OK.
  4. Run the following command:

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

    Note   The AllowRedirection parameter enables cloud-based organizations in datacenters all over the world to connect Windows PowerShell to the cloud-based service by using the same URL.

  5. Run the following command:

    Import-PSSession $Session

    A progress indicator appears that shows the importing of commands used in the cloud-based service into the client-side session of your local computer. When this process is complete, you can run these commands.

Disconnect Windows PowerShell from the cloud-based service

When you’re finished using the server-side session, always disconnect Windows PowerShell by running the following command:

Remove-PSSession <session variable>

For example, to disconnect from the server-side session that is defined by the $Session variable, run the following command:

Remove-PSSession $Session

Important   If you close the Windows PowerShell window without disconnecting from the server-side session, your connection will remain open for 15 minutes. Your account can only have three connections to the server-side session at one time.”

Original Source here: http://help.outlook.com/en-us/140/cc952755.aspx