Wednesday, August 21, 2013

Office 365 - How to connect Powershell to Office 365 Service

How to connect Powershell to the Office365 Server, so that you can administer a Hybrid environment.

Issue the following commands:
  • Set-ExecutionPolicy Unrestricted
  • $cred = Get-Credential
    (Enter your Tenant Login to Office365)
  • $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential $Cred -Authentication Basic -AllowRedirection
    (Note: You may get a redirection as this command is executed:
    WARNING: Your connection has been redirected to the following URI:
    "
    https://pod51042psh.outlook.com/powershell-liveid?PSVersion=3.0 ")
  • Import-PSSession $Session
Before issuing this command, following are the Modules that were loaded:
PS>Get-Module
ModuleType Name                                ExportedCommands
---------- ----                                ----------------
Manifest   Microsoft.PowerShell.Management     {Add-Computer, Add-Content, Cheomputer, Clear-Content...}
Manifest   MSOnline                            {Add-MsolForeignGroupToRole, Add-MAdd-MsolRoleMember,...


After issuing a successful connection to the Office365 Service, you now have the following:
PS C:\Windows\system32> Get-Module
ModuleType Name                                ExportedCommands
---------- ----                                ----------------
Manifest   Microsoft.PowerShell.Management     {Add-Computer, Add-Content, Checkpoint-Co...}
Manifest   Microsoft.PowerShell.Security       {ConvertFrom-SecureString, ConvertTo-Secu...
Manifest   Microsoft.PowerShell.Utility        {Add-Member, Add-Type, Clear-Variable, Compare-Object...}
Manifest   MSOnline                            {Add-MsolForeignGroupToRole, Add-MsolGroupMember, ...
Script     tmp_fhnxmnma.xiw                    {Add-AvailabilityAddressSpace, Add-Distribution...


This module adds 469 new commands.

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

No comments: