Powershell Direct Remoting error

Welcome Forums General PowerShell Q&A Powershell Direct Remoting error

This topic contains 8 replies, has 3 voices, and was last updated by

 
Participant
1 year, 3 months ago.

  • Author
    Posts
  • #54359

    Participant
    Points: 0
    Rank: Member

    I have Windows 10 and enabled hyper-v.

    I am trying to connect to a VM that is running locally and not joined to the domain

    heres my code:

    Enter-PSSession -VMName 'ref001' -Credential (Get-Credential "$env:COMPUTERNAME\Hman")

    And the error .... any help would be great . Thank you

    Enter-PSSession : An error has occurred which Windows PowerShell cannot handle. A remote
    session might have ended.
    At line:1 char:1
    + Enter-PSSession -VMName 'ref001' -Credential (Get-Credential "$env:CO ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : ResourceUnavailable: (:) [Enter-PSSession], PSRemotingData
    StructureException
    + FullyQualifiedErrorId : System.Management.Automation.Remoting.PSRemotingDataStruct
    ureException,Microsoft.PowerShell.Commands.EnterPSSessionCommand

  • #54362

    Participant
    Points: 0
    Rank: Member

    Because the VM is not joined to a domain, you need to manually add the host name of the VM to the TrustedHosts list on your Windows 10 computer. This should resolve the issue, given that the VM and your Windows 10 system are on the same network.

    Set-Item WSMan:\localhost\Client\TrustedHosts -Value 'ref001' -Concatenate
    

    Once that is done you need to also ensure that PSRemoting is enabled on the VM which will take care of all the WinRM, opening firewall ports, etc.

  • #54363

    Participant
    Points: 0
    Rank: Member

    I just tried it , and I am still getting the error..

    it is also requiring a credential , while the cmdlet without the -vmname does not? BUG?

  • #54365

    Participant
    Points: 0
    Rank: Member

    There may be better approaches but it appears your Enter-PSSession is using a credential from your computer's local session rather than authenticating against a local account on the VM (I assume that's what you need to do).

    Try this:

    Enter-PSSession -VMName 'ref001' -Credential (Get-Credential "[VMHostName]\[LocalAccountName]")
  • #54366

    Participant
    Points: 0
    Rank: Member

    great idea , but still the same error... im baffled

  • #54371

    Participant
    Points: 0
    Rank: Member

    Are you up for using -ComputerName instead of -VMName?

  • #54381

    Participant
    Points: 0
    Rank: Member

    no i am using -VMName

  • #54383

    Participant
    Points: 0
    Rank: Member

    i think it may have to do with the version VM i am running

    http://byronwright.blogspot.com/2016/05/error-using-powershell-direct.html

  • #77379

    Participant
    Points: 1
    Rank: Member

    Go into your Hyper-V-Manager. Right Click on your VM, go to Settings, Integration Services. Make sure they are all Activated.

The topic ‘Powershell Direct Remoting error’ is closed to new replies.