Skip to content

New-PSSession still fails with a NullReferenceException on macOS #4029

Description

I believe this is related to #942, which is closed. Someone claimed this works from Ubuntu. Is this not supported on macOS, or is this a bug?

Steps to reproduce

$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.compliance.protection.outlook.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection

Expected behavior

Session would be initiated

Actual behavior

Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object.
   at System.Management.Automation.Remoting.PrioritySendDataCollection.Clear()
   at System.Management.Automation.Remoting.Client.BaseClientTransportManager.CloseAsync()
   at System.Management.Automation.Remoting.Client.WSManClientSessionTransportManager.CloseAsync()
   at System.Management.Automation.Remoting.Client.BaseClientTransportManager.Finalize()
Abort trap: 6

Environment data

> $PSVersionTable

Name                           Value                                                           
----                           -----                                                           
PSVersion                      6.0.0-beta                                                      
PSEdition                      Core                                                            
BuildVersion                   3.0.0.0                                                         
CLRVersion                                                                                     
GitCommitId                    v6.0.0-beta.2                                                   
OS                             Darwin 17.0.0 Darwin Kernel Version 17.0.0: Mon May 29 20:35:...
Platform                       Unix                                                            
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                         
PSRemotingProtocolVersion      2.3                                                             
SerializationVersion           1.1.0.1                                                         
WSManStackVersion              3.0  

Activity

  1. tthoma24 commented on Jun 17, 2017

    @tthoma24
    Author

    #3476 may also be related, same issue on CentOS, and another reporter on macOS.

  2. tthoma24 commented on Aug 1, 2017

    @tthoma24
    Author

    I'm not sure what's meant when asked for a "simpler repro," but I was able to reproduce my issue again in a VM running 10.12.6 and the beta 4 release of PowerShell.

  3. kai-h commented on Nov 22, 2017

    @kai-h

    I've got this issue on macOS 10.12.6 and 10.13 with 6.0.0-rc

    This is installing PowerShell via the macOS Installer Package. Apparently you can install it via Homebrew as well however the way that Homebrew opens up the permissions on some of the system binary directories (like /usr/local/bin) to make it group read/write is a security risk so I can't use it to test.

    PowerShell v6.0.0-rc
    Copyright (c) Microsoft Corporation. All rights reserved.
    
    https://aka.ms/pscore6-docs
    Type 'help' to get help.
    
    PS /Users/kai> $PSVersionTable                                                  
    
    Name                           Value                                           
    ----                           -----                                           
    PSVersion                      6.0.0-rc                                        
    PSEdition                      Core                                            
    GitCommitId                    v6.0.0-rc                                       
    OS                             Darwin 16.7.0 Darwin Kernel Version 16.7.0: T...
    Platform                       Unix                                            
    PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                         
    PSRemotingProtocolVersion      2.3                                             
    SerializationVersion           1.1.0.1                                         
    WSManStackVersion              3.0                                             
    
    
    PS /Users/kai> $UserCredential = Get-Credential                                 
    
    PowerShell credential request
    Enter your credentials.
    User: [email protected]
    Password for user [email protected]: ********
    
    PS /Users/kai> $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid -Credential $UserCredential -Authentication Basic -AllowRedirection                                                                                          
    
    An error has occurred that was not properly handled. Additional information is shown below. The PowerShell process will exit.
    
    Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object.
       at System.Management.Automation.Remoting.PrioritySendDataCollection.Clear()
       at System.Management.Automation.Remoting.Client.BaseClientTransportManager.CloseAsync()
       at System.Management.Automation.Remoting.Client.WSManClientSessionTransportManager.CloseAsync()
       at System.Management.Automation.Remoting.Client.BaseClientTransportManager.Finalize()
    Abort trap: 6
    
  4. iSazonov commented on Nov 23, 2017

    @iSazonov
    Collaborator

    Steve Lee (@SteveL-MSFT) Related Issue #3476 was labeled as GA. Should we fix current Issue before GA too?

  5. SteveL-MSFT commented on Nov 23, 2017

    @SteveL-MSFT
    Member

    Dan Travison (@dantraMSFT) can you confirm with latest psl-omi-provider this works on macOS?

  6. dantraMSFT commented on Nov 28, 2017

    @dantraMSFT
    Contributor

    Kai Howells (@kai-h) Are you able to consistently repro the NullReferenceException? I'm not able to repro it.

  7. kai-h commented on Nov 28, 2017

    @kai-h

    I can consistently reproduce this on two separate Macs. One with macOS 10.12 and one with 10.13.
    It happens every single time - as in I have never been able to establish a New-PSSession on either of the two Macs I use.
    I don't have a Linux workstation to test with the latest psl-omi-provider - I only have Ubuntu on Windows 10 available without creating a new VM for testing purposes.

  8. kai-h commented on Nov 28, 2017

    @kai-h

    My environment is a pretty standard macOS installation with 10.12 or 10.13 and PowerShell 6.0.0-rc installed via the macOS Installer Package (.pkg) from the GitHub Releases page.
    I haven't built it from source or installed via Homebrew.
    Searching for more info on this error, in one thread (that I now can't find) someone reported that it was failing for them when they installed from the .pkg but when they installed from Homebrew it worked.

  9. dantraMSFT commented on Nov 28, 2017

    @dantraMSFT
    Contributor

    Thanks, Kai Howells (@kai-h), let me checkout out the pkg page.

  10. dantraMSFT commented on Nov 28, 2017

    @dantraMSFT
    Contributor

    Kai Howells (@kai-h), unfortunately, I'm still not able to repro it. Would you change the file size and date stamps of libmi.dylib and libpsrpclient.dylib?
    cd $pshome
    ls -l lib*

  11. 36 remaining items

  12. dantraMSFT commented on Dec 4, 2017

    @dantraMSFT
    Contributor

    Kai Howells (@kai-h): There's a bug in workaround I gave you. I'll give you another drop shortly to see if it resolves the problem of if there's something else going on.

  13. kai-h commented on Dec 4, 2017

    @kai-h

    Mark Kraus (@markekraus) - That command works in that when I give it my Office 365 credentials it displays lots of information about my user account and mailbox (I won't copy and paste it here) however it never returns to the command prompt. Even Ctrl+C doesn't kill it, the only solution appears to be to close the Terminal window.

  14. kai-h commented on Dec 4, 2017

    @kai-h

    Mark Kraus (@markekraus) - re symlinking to /usr/local/opt/openssl/lib
    MacPorts installs the OpenSSL libraries in /opt/local/lib - I could try symlinking this to /usr/local/opt/openssl/lib for testing purposes, however there are likely to be other libraries in here other than the OpenSSL libraries if the end user has installed more packages with MacPorts.

  15. dantraMSFT commented on Dec 4, 2017

    @dantraMSFT
    Contributor

    Kai Howells (@kai-h): The updated binary and pdb file is on dropbox.

  16. kai-h commented on Dec 6, 2017

    @kai-h

    Thank you for the new binaries. I have installed them and now I don't get an error when I invoke New-PSSession and the following command runs and returns to the command prompt.
    e.g. If I then run Import-PSSession $PSSession, it imports the modules and returns me to the command prompt as expected.

    I haven't tried executing any further remote commands against Office 365 yet, except for the Invoke-Command listed above, which seems to behave as it should

    Invoke-Command -Session $Session -ScriptBlock { get-mailbox -ResultSize 1 }
    

    This seems to give me a heap of information about my mailbox.

    Again, thank you for the huge amount of work that must have gone in to supporting PowerShell on non-Windows platforms, and for the attention you have given to this particular issue.

    I would like to see the dependance on Homebrew installed OpenSSL libraries eliminated for the reasons mentioned above. I will test the workaround of symlinking the libraries from MacPorts (which does play nicely with sudo and doesn't change the ownership of system directories).

    For the final release version, is it likely that PowerShell will ship with all the required dependancies, or will it rely on these libraries to be installed via 3rd party package managers?

  17. dantraMSFT commented on Dec 6, 2017

    @dantraMSFT
    Contributor

    Kai Howells (@kai-h) Go ahead and file an issue MacPorts/Homebrew. Please include enough detail so a MacOS neophyte like myself can understand it. :)

    Thanks again for all of your help tracking this down.

  18. kai-h commented on Dec 6, 2017

    @kai-h

    Dan Travison (@dantraMSFT) - I will do. Thanks.

  19. kai-h commented on Dec 6, 2017

    @kai-h

    I have logged issue #5634 regarding this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Issue-BugIssue has been identified as a bug in the productOS-macOSResolution-FixedThe issue is fixed.WG-RemotingPSRP issues with any transport layer

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions