Office 365 远程登陆命令

之前管理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
相关文章
相关标签/搜索