【转载】Powershell连接世纪互联Office365
1 $User = "admin@contoso.com" 2 $PWord = ConvertTo-SecureString –String "password" –AsPlainText -Force 3 $Credential = New-Object –TypeName System.Management.Automation.PSCredential –ArgumentList $User, $PWord 4 Import-Module MSOnline 5 Connect-MsolService -Credential $Credential 6 $sessionOption = New-PSSessionOption -SkipRevocationCheck 7 $ExchangeShell = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://partner.outlook.cn/PowerShell-LiveID?PSVersion=2.0 -Credential $Credential -Authentication Basic -AllowRedirection -SessionOption $sessionOption 8 $importresults = Import-PSSession $ExchangeShell