Skip to content

New-PSSession fails with Could not load file or assembly 'System.Security.Cryptography' #18671

Closed
@P-39-Airacobra

Description

@P-39-Airacobra

Prerequisites

Steps to reproduce

  1. Install PowerShell v7.3.0 on a remote computer.
  2. Execute the following PowerShell script on the local machine:

New-PSSession -ComputerName <remote-computer> -Credential (Get-Credential) | Enter-PSSession;

The issue occurs when the remote computer has PowerShell v7.3.0 installed. It works fine when PowerShell v7.2.7 is installed on the remote computer.

Expected behavior

A remote PowerShell session is created and opened.

Actual behavior

The following error occurs:

New-PSSession: [<remote-computer>] Connecting to remote server <remote-computer> failed with the following error message : Could not load file or assembly 'System.Security.Cryptography, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified. For more information, see the about_Remote_Troubleshooting Help topic.

Error details

Exception             :
    Type        : System.Management.Automation.Remoting.PSRemotingTransportException
    ErrorCode   : -2141974624
    ErrorRecord :
        Exception             :
            Type    : System.Management.Automation.ParentContainsErrorRecordException
            Message : Connecting to remote server <remote-computer> failed with the following error message : Could not load file or assembly
'System.Security.Cryptography, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified. For more
information, see the about_Remote_Troubleshooting Help topic.
            HResult : -2146233087
        CategoryInfo          : ResourceUnavailable: (:) [], ParentContainsErrorRecordException
        FullyQualifiedErrorId : System.Management.Automation.Remoting.PSRemotingDataStructureException
    Message     : Connecting to remote server remote-computer failed with the following error message : Could not load file or assembly
'System.Security.Cryptography, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified. For more
information, see the about_Remote_Troubleshooting Help topic.
    HResult     : -2146233087
TargetObject          : System.Management.Automation.RemoteRunspace
CategoryInfo          : OpenError: (System.Management.A…tion.RemoteRunspace:RemoteRunspace) [New-PSSession], PSRemotingTransportException
FullyQualifiedErrorId : IncorrectProtocolVersion,PSSessionOpenFailed
ErrorDetails          : [remote-computer] Connecting to remote server remote-computer failed with the following error message : Could not load file or assembly
'System.Security.Cryptography, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified. For more
information, see the about_Remote_Troubleshooting Help topic.
InvocationInfo        :
    MyCommand        : New-PSSession
    ScriptLineNumber : 1
    OffsetInLine     : 1
    HistoryId        : 66
    Line             : New-PSSession -ComputerName <remote-computer> -Credential (Get-Credential) | Enter-PSSession;
    PositionMessage  : At line:1 char:1
                       + New-PSSession -ComputerName <remote-computer> -Credential (Get-Credential) | En …
                       + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    InvocationName   : New-PSSession
    CommandOrigin    : Internal
ScriptStackTrace      : at <ScriptBlock>, <No file>: line 1
PipelineIterationInfo :

Environment data

Local machine:

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



Remote machine:

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

Visuals

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions