Today's main talk about using PowerShell to manage Office 365 can be divided into office365 user management, Exchange online management, etc.
1. Use PowerShell to link to the Office 365 User management interface
Need to install Login Assistant and Azure AD module first
Run under Windows PowerShell:
Get-executionpolicy
Set-executionpolicy remotesigned//Change execution policy, execute once is enough
$credential = get-credential//Create credentials
$credential//Authentication credentials
* Connect to office365 above (first import module, install login Assistant, Azure ad module)
* Note that if Azure Adconnect is installed, the prerequisites are automatically installed successfully
Import-module MsOnline//import office365 module
Get-module//Verify whether to import the module, if return manifest MSOnline {add-msoladministrativeunitme ... That is, the import module succeeds
Connect-msolservice-credential $credential//connected to office365
Get-msoldomain
or using a comprehensive code
" [email protected] " "password" –asplaintext-= New-object-typename System.Management.Automation.PSCredential-argumentlist $User, $PwordImport-Module msonlineconnect -msolservice-credential $Credential
2. Use PowerShell to link to the Office 365 Exchange Online Management interface
Run under Windows PowerShell:
Set-executionpolicy remotesigned
$UserCredential = get-credential//(Get login credentials for office365)
$Session = New-pssession-configurationname Microsoft.exchange-connectionuri Https://partner.outlook.cn/PowerShell- Credential $UserCredential-authentication basic–allowredirection//International version URL for; Https://outlook.office365.com/powershell-liveid/
Import-pssession $Session
or using a comprehensive code
Linking to Office 365 with PowerShell