以前管理Office365的時候,需要經常登錄後臺查看用戶郵件信息,配置用戶郵箱屬性等等,下面的腳本可以讓管理員快速登錄後臺。
方法一: #region Online-Session function Online-Session(){ $UserCredential = Get-Credential -Credential [email protected] $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 [email protected] 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