Connecting to Office 365

#credential Variable

$credential = Get-Credential

# Connecting to Office 365.

Import-Module MsOnline
Connect-MsolService -Credential $credential

#Connecting to Exchange (Office365)

$exchangeSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $credential -Authentication “Basic” -AllowRedirection
Import-PSSession $exchangeSession -DisableNameChecking

#Lesser used commands

#Connecting to SharePoint Online. Replace domainhost with the actual value for your domain.

Import-Module Microsoft.Online.SharePoint.PowerShell -DisableNameChecking
Connect-SPOService -Url https://domainhost-admin.sharepoint.com -credential $credential
#Connecting to Skype for Business Online. A warning about increasing the WSMan NetworkDelayms value is expected the first time you connect and should be ignored.
Import-Module LyncOnlineConnector
$sfboSession = New-CsOnlineSession -Credential $credential
Import-PSSession $sfboSession
#Connecting to the Compliance Center.
$ccSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.compliance.protection.outlook.com/powershell-liveid/ -Credential $credential -Authentication Basic -AllowRedirection
Import-PSSession $ccSession -Prefix cc
#NoteNote: The text prefix “cc” is added to all Compliance Center cmdlet names so you can run cmdlets that exist in both Exchange Online and the Compliance Center in the same Windows PowerShell session. For example, Get-RoleGroup becomes Get-ccRoleGroup in the Compliance Center.
# Disconnecting Session
Remove-PSSession $sfboSession ; Remove-PSSession $exchangeSession ; Remove-PSSession $ccSession ; Disconnect-SPOService

Leave a Reply

Your email address will not be published. Required fields are marked *