之前管理Office365的時候,須要常常登陸後臺查看用戶郵件信息,配置用戶郵箱屬性等等,下面的腳本可讓管理員快速登陸後臺。shell
方法一: #region Online-Session function Online-Session(){ $UserCredential = Get-Credential -Credential account@xxx.com $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://partner.outlook.cn/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection Import-PSSession $Session } #endregion 方法二:(包含方法一的功能,而且能夠管理License,我一直在使用這個) #region Online-MsolService function Online-MsolService{ Import-Module MsOnline $cred=Get-Credential -Credential account@xxx.com Connect-MsolService -Credential $cred -errorAction silentlyContinue -errorvariable er $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://partner.outlook.cn/PowerShell-LiveID -Credential $cred -Authentication Basic -AllowRedirection Import-PSSession $Session -AllowClobber } #endregion