Connecting to Office 365 / Exchange Online with PowerShell

Configurare noua (How To)

Situatie

This article shows how you can connect to Office 365 / Exchange Online using PowerShell.

Solutie

Pasi de urmat

Preparation of Windows PowerShell

The Windows PowerShell cmdlets for Office 365 management and deployment have to be installed on your local machine, if you want to manage e.g. Office 365 licences.

    1. Please download the appropriate version of the Microsoft Online Services Sign-in Assistant depending on your operating system version: http://technet.microsoft.com/en-us/library/hh974317.aspx.

2. Install the downloaded software on your local machine.

  1. Open the Windows PowerShell.

Execute the follwoing command if the Microsoft Online Services Sign-in Assistant has been installed: Import-Module MSOnline 

$LiveCred = Get-Credential and enter the admin credentials in the popup dialog.

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

 

You are connected now. If the Microsoft Online Services Sign-in Assistant has been installed, execute the following command:
Connect-MsolService –Credential $LiveCred

Enter credentials without popup dialog

You can enter the credentials directly in the script without using a popup dialog. This method may be used to automate PowerShell commands.

  1. Use the following commands instead of $LiveCred = Get-Credential and replace the credentials:
    $Username = "admin@yourdomain.edu"
    $Password = ConvertTo-SecureString ‘YourPassword’ -AsPlainText -Force
    $LiveCred = New-Object System.Management.Automation.PSCredential $Username, $Password

Tip solutie

Permanent

Voteaza

(8 din 16 persoane apreciaza acest articol)

Despre Autor

Leave A Comment?