【问题标题】:Connect to Exchange from PowerShell on Linux在 Linux 上从 PowerShell 连接到 Exchange
【发布时间】:2021-01-13 15:10:41
【问题描述】:

我尝试按照https://docs.microsoft.com/de-de/powershell/exchange/connect-to-exchange-online-powershell?view=exchange-ps 上的说明进行操作,但它们似乎不适用于 Linux:

$ pwsh
PowerShell 7.1.0
Copyright (c) Microsoft Corporation.

https://aka.ms/powershell
Type 'help' to get help.

PS /home/info> Install-Module -Name ExchangeOnlineManagement

PS /home/info> $O365Credential = Get-Credential                                                                                                                                                                  
PowerShell credential request
Enter your credentials.
User: john.doe@mydomain.com
Password for user john.doe@mydomain.com: ***********

PS /home/info> Connect-ExchangeOnline -Credential $UserCredential                                                                                                                                                                                                           ----------------------------------------------------------------------------                                                          The module allows access to all existing remote PowerShell (V1) cmdlets in addition to the 9 new, faster, and more reliable cmdlets.                                                                                                                                        
|--------------------------------------------------------------------------|
|    Old Cmdlets                    |    New/Reliable/Faster Cmdlets       |
|--------------------------------------------------------------------------|
|    Get-CASMailbox                 |    Get-EXOCASMailbox                 |
...
----------------------------------------------------------------------------

New-ExoPSSession: /home/info/.local/share/powershell/Modules/ExchangeOnlineManagement/2.0.3/ExchangeOnlineManagement.psm1:426
Line |
 426 |  … PSSession = New-ExoPSSession -ExchangeEnvironmentName $ExchangeEnviro …
     |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Could not load file or assembly 'System.Windows.Forms, Version=4.0.0.0, Culture=neutral,
     | PublicKeyToken=b77a5c561934e089'. The system cannot find the file specified. .

因为无法在 Linux 系统上运行 System.Windows.Forms 而失败。

还有其他方法可以在 Linux 上从 Powershell 连接到 Exchange?

【问题讨论】:

    标签: linux powershell office365


    【解决方案1】:

    试试这个(在 Linux Kali 最新版本上测试)它对我有用:

    Install-Module -Name ExchangeOnlineManagement -AllowPrerelease
    $url = "https://github.com/jborean93/omi/releases/download/v1.2.0-pwsh/libmi-centos7.so"
    $output = "/opt/microsoft/powershell/7/libmi.so"
    Invoke-WebRequest -Uri $url -OutFile $output
    Import-Module ExchangeOnlineManagement
    Connect-ExchangeOnline -Device
    

    http://blog.icewolf.ch/archive/2020/09/25/exchange-online-powershell-v2-module-supports-powershell-7-and-linux.aspx

    https://docs.microsoft.com/en-us/powershell/exchange/exchange-online-powershell-v2?view=exchange-ps

    【讨论】:

      猜你喜欢
      • 2016-07-14
      • 2015-10-03
      • 2015-03-17
      • 1970-01-01
      • 1970-01-01
      • 2020-10-06
      • 2016-05-07
      • 2021-01-23
      • 2020-12-20
      相关资源
      最近更新 更多