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

Viewing 3 reply threads
  • 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: 2
      Replies: 1752
      Points: 3,621
      Helping Hand
      Rank: Community Hero

      Try …

      Get-PSSession | Where-Object {$_.ComputerName -eq 'china'}
    • #170866
      Participant
      Topics: 2
      Replies: 1
      Points: 8
      Rank: Member

      Try …

      <textarea class=”ace_text-input” style=”opacity: 0; height: 18px; width: 6.59781px; left: 44px; top: 0px;” spellcheck=”false” wrap=”off”></textarea>

      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: 2
      Replies: 1752
      Points: 3,621
      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.

Viewing 3 reply threads
  • The topic ‘[help] Get-Pssession not filtering on -Computername’ is closed to new replies.