daknetworks.com

You are here: Blog Powershell Connect To AzureAD | Connect to Office365

Powershell Connect To AzureAD | Connect to Office365

This information is in other articles that are posted but they can be overly complicated. This is the TLDR version.

Start Powershell

  • -start POWERSHELL (as administrator).
  • -type: $LiveCred = Get-Credential
  • -type in your username/password.

Office365 Endpoints | O365 Endpoints | Azure Endpoints | Microsoft Online Endpoints

From here you have the option to connect to different ENDPOINTS of Office365/AzureAD. The information is the same but data is displayed differently depending on which endpoint is being used.

The ENDPOINTS I use regularly are:

  1. OUTLOOK/Exchange-Online
  2. AzureAD
  3. MSOnline
  4. Skype-for-Business/Teams
  5. Microsoft Teams

Note that all modules can be found here (although look closely as the names can be unnatural to some):
https://docs.microsoft.com/en-us/powershell/module/

See Installed Modules

If you want to see the installed modules, you can view by:

Get-InstalledModule

Install Module

To connect to the endpoints, a module must be installed into Powershell. So if this is the first time, depending on the endpoint,use the following

  1. Outlook/Exchange-Online: type: Install-Module ExchangeOnlineManagement
  2. AzureAD: type: Install-Module AzureAD (or Install-Module AzureADPreview)
  3. MSOline: type: Install-Module MSOnline
  4. Skype-for-Business/Teams: Import-Module SkypeOnlineConnector
  5. Teams: Install-Module MicrosoftTeams

Note that this only has to be done once. After the module is installed into Powershell, it remains.

Also note that since the AzureAd module is being actively developed, the "preview" module, or beta-version, has additional commands that the current release does not. However only one of the AzureAD modules (either AzureAD or AzureADPreview) can be installed at a time.

Connect to Endpoint

After the module is installed into Powershell, the connection is as follows:

  1. OUTLOOK/Exchange-Online: type:
    Connect-ExchangeOnline -UserPrincipalName This e-mail address is being protected from spambots. You need JavaScript enabled to view it
    Connect-ExchangeOnline -UserPrincipalName This e-mail address is being protected from spambots. You need JavaScript enabled to view it -DelegatedOrganization adatum.onmicrosoft.com
    Old-way: $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential $LiveCred -Authentication Basic -AllowRedirection
    Import-PSSession $Session -AllowClobber
  2. AzureAD: Connect-azuread -Credential $LiveCred
    Import-PSSession $Session -AllowClobber
  3. MSOnline: Connect-MsolService -Credential $LiveCred
  4. Skype-for-Business/Teams: type:
    $sfbSession = New-CsOnlineSession -Credential $LiveCred
    Import-PSSession $sfbSession
  5. Teams: Connect-microsoftteams -Credential $LiveCred
    Import-PSSession $Session -AllowClobber

Which Endpoint Is Best

It depends on what you are trying to do.

  1. OUTLOOK/Exchange-Online: for the Exchange portion of Office365. Should be easy to determine if it is needed.
  2. AzureAD: new endpoint that seems to have development in the works. To me the commands are long and arduous but it has the advantage of automation or workflow.
  3. MSOnline: tried and true as a legacy option that seems to work best.
  4. Skype-for-Business/Teams: for the Skype-for-Business/Teams portion of Office365.
  5. Teams: for the Microsoft Teams portion of Office365.

Uninstall Module

Here is how to uninstall a module:

Uninstall-Module ModuleNameHere
(ie: Uninstall-Module AzureAD)

Contact Dak Networks

We are not taking on new clients at this time.