jborean93/omi

PowerShell 7.1.2 on macOS Mojave Enter-PSSession does not work

greeneg opened this issue · 2 comments

SUMMARY

When trying to use the Enter-PSSession commandlet, I get the following error:

PS /Users/ggreen99/Development/tfrun-srvr-webui/src> Enter-PSSession -ComputerName $server
Enter-PSSession: This parameter set requires WSMan, and no supported WSMan client library was found. WSMan is either not installed or unavailable for this system.
LIBMI VERSION

Cannot find that script in the repo to get the version. The library was installed using the Install-WSMan commandlet with root rights on my Mac

OS / ENVIRONMENT

macOS Mojave 10.14.6

The first thing to try is to run the following

PWSHDIR="$( dirname "$( readlink "$( which pwsh )" )" )"
otool -L "${PWSHDIR}/libpsrpclient.dylib"
otool -L "${PWSHDIR}/libmi.dylib"

This should output a whole bunch of paths to .dylib files that the libraries are linked to. You need to ensure that they exist. One that is commonly the cause of problems is the libssl and libcrypto libraries which come from OpenSSL. These are hardcoded to the path at /usr/local/opt/openssl@1.1/lib/... which is the path that brew installs them to. If these don't exist then you either need to install OpenSSL 1.1.x and symlink to this location or use install_name_tool to change the location like

install_name_tool -change \
    /usr/local/opt/openssl@1.1/lib/libssl.1.1.dylib \
    /new/location/libssl.1.1.dylib \
    /usr/local/microsoft/powershell/7/libmi.dylib

install_name_tool -change \
    /usr/local/opt/openssl@1.1/lib/libcrypto.1.1.dylib \
    /new/location/libcrypto.1.1.dylib \
    /usr/local/microsoft/powershell/7/libmi.dylib

This must be for OpenSSL 1.1.x and not 1.0.0 or the builtin LibreSSL provided by Apple. Personally I don't think you should change the location as you will need to do that everytime you update PowerShell or install a new copy of this library but it's up to you.

If those libraries are installed the next thing to try is to set the env var DYLD_PRINT_APIS=1 when you run pwsh. The simplest way is to run DYLD_PRINT_APIS=1 pwsh -Command Enter-PSSession -ComputerName localhost to test it out. The command ultimately fails because localhost isn't a valid WSMan target (or the library couldn't be loaded) but you will get a whole bunch of output from the dynamic loader that would hopefully indicate what failed to load. For example when the OpenSSL libraries weren't present I would get the following in the output.

dlopen_internal(/usr/local/microsoft/powershell/7/libpsrpclient.dylib, 0x00000001)
dlclose(), found unused image 0x7fa794f45eb0 libpsrpclient.dylib
dlclose(), found unused image 0x7fa794f46100 libmi.dylib
dlclose(), deleting 0x7fa794f45eb0 libpsrpclient.dylib
dlclose(), deleting 0x7fa794f46100 libmi.dylib
  dlopen_internal() failed, error: 'dlopen(/usr/local/microsoft/powershell/7/libpsrpclient.dylib, 1): Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
  Referenced from: /usr/local/microsoft/powershell/7/libmi.dylib
  Reason: image not found'
dlerror()
dlopen_internal(/usr/local/microsoft/powershell/7/libpsrpclient.dylib, 0x00000001)
dlclose(), found unused image 0x7fa794f46970 libpsrpclient.dylib
dlclose(), found unused image 0x7fa794f46100 libmi.dylib
dlclose(), deleting 0x7fa794f46970 libpsrpclient.dylib
dlclose(), deleting 0x7fa794f46100 libmi.dylib
  dlopen_internal() failed, error: 'dlopen(/usr/local/microsoft/powershell/7/libpsrpclient.dylib, 1): Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
  Referenced from: /usr/local/microsoft/powershell/7/libmi.dylib
  Reason: image not found'
dlerror()
dlopen_internal(libpsrpclient.dylib, 0x00000001)
dlclose(), found unused image 0x7fa794f46970 libpsrpclient.dylib
dlclose(), found unused image 0x7fa794f46100 libmi.dylib
dlclose(), deleting 0x7fa794f46970 libpsrpclient.dylib
dlclose(), deleting 0x7fa794f46100 libmi.dylib
  dlopen_internal() failed, error: 'dlopen(libpsrpclient.dylib, 1): Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
  Referenced from: /usr/local/microsoft/powershell/7/libmi.dylib
  Reason: image not found'
dlerror()

Can you share the output when you run that command?

Closing due to no response.