[help] Get-Pssession not filtering on -Computername

Welcome Forums General PowerShell Q&A [help] Get-Pssession not filtering on -Computername

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

 
Participant
1 month ago.

  • Author
    Posts
  • #170824

    Participant
    Topics: 2
    Replies: 1
    Points: 8
    Rank: Member

    PS C:\Users\xxxx\source\repos\Datacenter> Get-PSSession

    Id Name ComputerName ComputerType State ConfigurationName Availability
    — —- ———— ———— —– —————– ————
    5 WinRM5 black-dove RemoteMachine Opened Microsoft.PowerShell Available
    4 WinRM4 china RemoteMachine Opened Microsoft.PowerShell Available

    PS C:\Users\xxxx\source\repos\Datacenter> Get-PSSession -ComputerName "china"
    PS C:\Users\xxxx\source\repos\Datacenter>

    Hi,

    Can anyone help on this please?

    Why is nothing being returned??? i have tried 'china' and china with no quotes and no session gets returned even though those sessions are clearly active in get-pssession

  • #170863

    Participant
    Topics: 1
    Replies: 1528
    Points: 2,581
    Helping Hand
    Rank: Community Hero

    Try ...

    Get-PSSession | Where-Object {$_.ComputerName -eq 'china'}
  • #170866

    Participant
    Topics: 2
    Replies: 1
    Points: 8
    Rank: Member

    Try ...

    1
    Get-PSSession | Where-Object {$_.ComputerName -eq 'china'}
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    Thanks that works , but i am really confused as this seems a long way of doing it? should -computername not work?

  • #170869

    Participant
    Topics: 1
    Replies: 1528
    Points: 2,581
    Helping Hand
    Rank: Community Hero

    The parameter -ComputerName is not a filter – it's a request for the cmdlet to run on the remote computer you specified.

You must be logged in to reply to this topic.