首页 > 代码库 > Office 365 远程登录命令

Office 365 远程登录命令

以前管理Office365的时候,需要经常登录后台查看用户邮件信息,配置用户邮箱属性等等,下面的脚本可以让管理员快速登录后台。



方法一:

#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


本文出自 “bxing” 博客,请务必保留此出处http://bxing.blog.51cto.com/1677994/1877922

Office 365 远程登录命令