PowerShell module providing functions to connect to Microsoft 365 online services and Exchange On-Premises, as well as perform module management.
After importing the module, the following functions are available:
Connect
Connect-EXOConnects to Exchange Online (wasConnect-ExchangeOnline)Connect-ExchangeConnects to Exchange On-Premises (wasConnect-ExchangeOnPremises)Connect-SCCConnects to Security & Compliance (wasConnect-IPPSSession)Connect-MSTeamsConnects to Microsoft TeamsConnect-AIPConnects to Azure Information ProtectionConnect-SPOConnects to SharePoint Online (wasConnect-SharePointOnline)Connect-PowerAppsConnects to Power AppsConnect-MGConnects to Microsoft Graph (Connect-MgGraph)Connect-PowerBIConnects to Power BI (Connect-PowerBIServiceAccount)Connect-PnPConnects to a SharePoint site via PnP PowerShell; use-SiteUrlto specify a site, defaults to tenant rootConnect-Office365Connects to EXO, Teams, SCC, and SPO by default; use-Serviceto target specific services
Disconnect & session
Disconnect-Office365Disconnects one or more servicesGet-Office365SessionShows the active identity and per-service connection statusTest-Office365ConnectivityTests reachability of key Microsoft 365 endpoints
Credentials & identity
Get-Office365CredentialGets Microsoft 365 credentialsGet-OnPremisesCredentialGets On-Premises credentialsGet-Office365TenantGets Microsoft 365 tenant nameGet-ExchangeOnPremisesFQDNGets FQDN for Exchange On-PremisesGet-TenantIDResolves tenant ID from a domain or UPN
Environment & preferences
Set-Office365EnvironmentConfigures endpoints and region (Default, GCC, GCCHigh, DoD, China, Germany, AzurePPE)Get-Office365ServicesReturns current module stateGet-Office365ServicesPreferencesDisplays all current preference values and the preferences file locationSet-Office365ServicesPreferencesSets persistent user preferences (see Preferences below)
Module management
Select-Office365ModulesInteractively install/uninstall Office 365 PowerShell modulesUpdate-Office365ModulesUpdates installed Office 365 modulesOptimize-Office365ModulesRemoves old module versionsMove-Office365ModulesMoves installed modules between AllUsers and CurrentUser scopeShow-Office365ModulesLists available and installed modulesSave-Office365ModuleStateSaves installed module versions to the preferences fileRestore-Office365ModuleStateReinstalls modules from the saved state; use-Recentfor latest versionsExport-Office365ModuleConfigExports the preferences file as JSON (-File)Import-Office365ModuleConfigImports a previously exported preferences file (-File)
PowerShell 5.1 or higher. Modules for the services you want to connect to must be installed — use Select-Office365Modules to manage them.
Install-Module -Name Connect-Office365ServicesOr with PSResourceGet:
Install-PSResource -Name Connect-Office365ServicesThen import the module (or add this to your PowerShell profile):
Import-Module Connect-Office365ServicesYou can back up your preferences and installed module versions to a JSON file, and restore them on another machine or after a clean OS installation.
Export-Office365ModuleConfig first snapshots the currently installed module versions (Save-Office365ModuleState) and then writes the full config — preferences and module state — to the specified file:
Export-Office365ModuleConfig -File C:\Backup\O365Config.jsonCopy the exported file to the new machine (with this module already installed), then import it:
Import-Office365ModuleConfig -File C:\Backup\O365Config.jsonThis imports the saved preferences and module configuration from the file.
After importing the config, reinstall the saved modules at their exact recorded versions:
Restore-Office365ModuleStateOr install the latest available version of each saved module instead:
Restore-Office365ModuleState -RecentUse Set-Office365ServicesPreferences to change settings and Get-Office365ServicesPreferences to view the current values. Preferences are persisted to %APPDATA%\Office365Services\config.json.
| Preference | Default | Description |
|---|---|---|
AllowPrerelease |
$false |
Allow pre-release module versions during install/update |
AzureEnvironment |
Default |
Target cloud environment (see Set-Office365Environment) |
Scope |
AllUsers |
Module install scope (AllUsers or CurrentUser) |
ProxyAccessType |
None |
WinHTTP proxy access type for module downloads |
NoBanner |
$false |
Suppress the ASCII art banner on module import |
NoQuote |
$false |
Suppress the random quote on module import |
NoReport |
$false |
Suppress the installed-module list on module import |
NoAutoConnect |
$false |
Suppress automatic credential prompts in connect functions; credentials must be cached first via Get-Office365Credential |
# View current preferences
Get-Office365ServicesPreferences
# Suppress banner and the module list on import
Set-Office365ServicesPreferences -NoBanner $true -NoReport $true
# Require credentials to be cached before connecting
Set-Office365ServicesPreferences -NoAutoConnect $trueSuppressing the banner or module report only affects displayed output; PSResourceGet detection still runs. If a private or public function file fails to load, module import stops and reports the failure.
Version 4.0 converted Connect-Office365Services from a standalone script into a proper PowerShell module. The following changes may require updating existing scripts or profiles that used the older .ps1 file:
- The script was previously downloaded and to be dot-sourced. A module is installed from PowerShell Gallery and imported.
- Internal helper functions are now private, e.g. Get-myModule, Find-myModule a.o.
- The module state variable is private to the module (myOffice365Services).
- The
USGovernmentenvironment was renamed toGCC. Connect-ComplianceCenterwas removed in v3.45; useConnect-IPPSSessioninstead.
The following connect functions had to be renamed to avoid collisions with cmdlets of the same name from first party modules, due to how modules handle conflicts compared to dot-sourcing scripts (eg. need to explicitly specify AllowClobber versus silent overloading):
| New cmdlet | Replaces | Connects to |
|---|---|---|
Connect-EXO |
Connect-ExchangeOnline |
Exchange Online |
Connect-Exchange |
Connect-ExchangeOnPremises |
Exchange On-Premises |
Connect-SCC |
Connect-IPPSSession |
Security & Compliance (IPPS) |
Connect-SPO |
Connect-SharePointOnline |
SharePoint Online |
See CHANGELOG.md for the full version history.
This project is licensed under the MIT License - see the LICENSE.md for details.