Connect to main Office 365 services in one PowerShell Window
Upon connection, the script will rename your PowerShell session title bar with current o365 default domain, in uppercase. This is useful if you have multiple PowerShell windows open that are connected to different tenants.
In Skype connection string, connect to default *.onmicrosoft.com domain, bypassing DNS. This helps if DNS is not set correctly in hybrid environment.
If there are invalid credentials, the script will only attempt to connect to Azure AD, then stop with error. Also, script will check if modules are installed before connecting to Office 365 PowerShell.
I know there are a lot of blogs out there on how to connect to each service in Office 365, so I decided to consolidate them into one and share my script. This script will connect to the main services available across E1 and E3 skus (Azure AD, Sharepoint Online, Skype Online, Exchange Online, & Compliance Center). Before you can connect, you’ll need to ensure you have the prerequisites installed. You’ll need 64-bit version of Windows because of the requirements for Skype for Business Online and Azure AD PowerShell modules.
The Office 365 account you use to connect with PowerShell must be a member of the Global Admin role. For more information about Office 365 permissions, see Office 365 Permissions.
You’ll need to install at least .NET Framework 4.5.2 and either Windows Management Framework 3.0 or Windows Management Framework 4.0.
You need to install modules that are required for Azure AD, SharePoint Online, and Skype for Business Online (see below). Exchange Online does not require any installation.
- Microsoft Online Service Sign-in Assistant for IT Professionals RTW
- Azure AD PowerShell V1 (64-bit version)
- SharePoint Online PowerShell Module
- Skype for Business PowerShell Module
Windows PowerShell needs to be configured to run scripts. To do this, run the following command in an elevated Windows PowerShell session (open PowerShell by selecting Run as administrator). Type the following to allow the script to run in your current PowerShell session only.
Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process –Force
For more information on execution policy, see Set-ExecutionPolicy.
Connect to Office 365 services
For easy access, place script in root volume (c:\), and call from any directory. The script will prompt for credentials by default, but if you want to suppress prompt and store credentials in the script (not-secure) there is a section to do so – this can be helpful with Office 365 lab environments.
Here is sample output.
Please download script from this link: connect_v5.3