PowerShell / MMI

Other
24 stars 17 forks source link

Unable to load shared library 'libmi.so' or one of its dependencies #42

Open markkuleinio opened 4 years ago

markkuleinio commented 4 years ago

Hi, I'm not sure if I'm in the correct repo, but I see other somewhat similar keywords here.

I'm trying to command Windows Server 2016 DHCP server with PowerShell Core on Linux. As there is no DhcpServer module for Linux (as I see it, please correct me if I'm wrong), I'm sending the commands from Linux to PowerShell Core on Windows Server 2019 ("middlebox") with Invoke-Command (over SSH, there is OpenSSH server on W2019, installed from Windows features). Thus, the topology is:

PS Core 6.2.3 on Linux (10.11.2.10) -----> PS Core 6.2.3 on W2019 (10.11.1.11) -----> PS 5.1.14393.3053 on W2016 (10.11.1.10) (all firewalls disabled for now, and using the administrator account for now)

The reason for this topology is that we are trying to avoid installing extra non-Microsoft software on the critical DHCP servers, so using the middlebox here is attempted to solve the problem of sending PS commands from Linux.

On Linux I first use:

PS /home/markku> $session = New-PSSession -HostName 10.11.1.11 -UserName administrator
administrator@10.11.1.11's password:
PS /home/markku>

With Invoke-Command, "general" commands work:

PS /home/markku> Invoke-Command $session -ScriptBlock { $PSVersionTable }

Name                           Value
----                           -----
Platform                       Win32NT
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
OS                             Microsoft Windows 10.0.17763
GitCommitId                    6.2.3
PSVersion                      6.2.3
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
PSEdition                      Core

PS /home/markku>

But the problem is when sending the Get-DhcpServerv4Scope command:

PS /home/markku> Invoke-Command $session -ScriptBlock { Import-Module -SkipEditionCheck DhcpServer ; Get-DhcpServerv4Scope -ComputerName 10.11.1.10 }
Unable to load shared library 'libmi.so' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: liblibmi.so.so: cannot open shared object file: No such file or directory
+ CategoryInfo          : OperationStopped: (10.11.1.11:String) [], PSRemotingTransportException
+ FullyQualifiedErrorId : JobFailure
+ PSComputerName        : 10.11.1.11

PS /home/markku>

So, PS Core on Linux is able to send commands to the W2019 middlebox, but specifically the DHCP server commands cause the error with libmi.so.

The same commands work fine when run on the W2019 middlebox (PS Core):

PS C:\Users\Administrator> Import-Module -SkipEditionCheck DhcpServer
PS C:\Users\Administrator> Get-DhcpServerv4Scope -ComputerName 10.11.1.10

ScopeId         SubnetMask      Name           State    StartRange      EndRange        LeaseDuration
-------         ----------      ----           -----    ----------      --------        -------------
10.11.1.0       255.255.255.0   10.11.1.0/24   Active   10.11.1.200     10.11.1.220     8.00:00:00
10.11.2.0       255.255.255.0   10.11.2.0/24   Active   10.11.2.200     10.11.2.220     8.00:00:00

PS C:\Users\Administrator>

So, what is this error with libmi.so, and how is that used when sending some commands with Invoke-Command, and not a problem with some other commands?

Thanks for any insight for this.

Markku

markkuleinio commented 4 years ago

More information: The Linux is Debian 9 Stretch, and I have installed omi 1.6.0.0:

$ dpkg -l omi
...
ii  omi                  1.6.0.0         amd64           Open Management Infrastructure

PowerShell Core is installed from Microsoft repo:

$ cat /etc/apt/sources.list.d/microsoft.list
deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-debian-stretch-prod stretch main
$ dpkg -l powershell
...
ii  powershell           6.2.3-1.debian. amd64           PowerShell is an automation and configuration
markkuleinio commented 4 years ago

Also tested from Windows 10 PowerShell Core, working:

PS C:\Program Files\PowerShell\6> $session = New-PSSession -HostName 10.11.1.11 -UserName administrator
administrator@10.11.1.11's password:
PS C:\Program Files\PowerShell\6> Invoke-Command $session -ScriptBlock { Import-Module -SkipEditionCheck DhcpServer ; Get-DhcpServerv4Scope -ComputerName 10.11.1.10 }

PSComputerName   : 10.11.1.11
RunspaceId       : 96257596-814f-4c05-8ea6-f7c47e9a9b70
ActivatePolicies : True
Delay            : 0
Description      :
EndRange         : 10.11.1.220
LeaseDuration    : 8.00:00:00
MaxBootpClients  : 4294967295
Name             : 10.11.1.0/24
NapEnable        : False
NapProfile       :
ScopeId          : 10.11.1.0
StartRange       : 10.11.1.200
State            : Active
SubnetMask       : 255.255.255.0
SuperscopeName   :
Type             : Dhcp

PSComputerName   : 10.11.1.11
RunspaceId       : 96257596-814f-4c05-8ea6-f7c47e9a9b70
ActivatePolicies : True
Delay            : 0
Description      :
EndRange         : 10.11.2.220
LeaseDuration    : 8.00:00:00
MaxBootpClients  : 4294967295
Name             : 10.11.2.0/24
NapEnable        : False
NapProfile       :
ScopeId          : 10.11.2.0
StartRange       : 10.11.2.200
State            : Active
SubnetMask       : 255.255.255.0
SuperscopeName   :
Type             : Dhcp

PS C:\Program Files\PowerShell\6>