To get the most out of your Office 365 Environment almost always requires establishing a Remote 365 Session.
NOTE:
Exchange Shell has been replaced by the EXO Exchange Shell to support OAUTH authentication over basic authentication and also supports DUO
#Connecting to Exchange Online
Set-ExecutionPolicy -scope CurrentUser RemoteSigned
Pause
#Capture administrative credential for future connections.
$UserCredential = Get-Credential
Pause
#Create Exchange Online session -Check later but maybe obsolite and commented out
###Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
Pause
#Import session commands
Import-PSSession $Session -DisableNameChecking
#Installs Module for MSO now called EXO
Install-Module -Name ExchangeOnlineManagement -Force
#Connects to the MSO Exchange Online Using #usercredentials
Connect-ExchangeOnline -UserPrincipalName sharif.rashedi@emeryville.org
#Instals Module for Sharepoint
Import-Module -Name Microsoft.Online.SharePoint.PowerShell
#[-UseRPSSession] [-ExchangeEnvironmentName <Value>] [-ShowBanner:$false] [-DelegatedOrganization <String>] [-PSSessionOption $ProxyOptions]
Important to know which ExchangeOnline/AzureAD Connect Cmdlet to use:
To connect to Azure AD for your Microsoft 365 subscription with an account name and password or with multi-factor authentication, run one of these commands from a Windows PowerShell command prompt. (It doesn’t have to be elevated.)
Office 365 cloud | Command |
---|---|
Office 365 Worldwide (+GCC) | Connect-MsolService |
Office 365 operated by 21 Vianet | Connect-MsolService -AzureEnvironment AzureChinaCloud |
Office 365 Germany | Connect-MsolService -AzureEnvironment AzureGermanyCloud |
Office 365 U.S. Government DoD and Office 365 U.S. Government GCC High | Connect-MsolService -AzureEnvironment USGovernment |