PS3 2nd ed; Month of Lunches CH 9 Pipeline deeper

Welcome Forums General PowerShell Q&A PS3 2nd ed; Month of Lunches CH 9 Pipeline deeper

Viewing 6 reply threads
  • Author
    Posts
    • #33517
      Participant
      Topics: 120
      Replies: 260
      Points: 238
      Rank: Participant

      I’m scratching my head why the example on page 111 won’t run without error in my lab

      Get-WmiObject -Credential domain\user -class Win32_bios -ComputerName (Get-Content .\temp\computers.txt)

      Error: Get-WmiObject : The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)

      Yet when I run this, it works:

      Get-WmiObject -Credential domain\user -class Win32_bios -ComputerName DC1,DC2,DC3

      Checking my .txt file, Get-content .\temp\computers.txt works as well.

      Appreciate any ideas..all the examples in the book have worked up to this one and am enjoying the book overall.

    • #33518
      Keymaster
      Topics: 18
      Replies: 4872
      Points: 1,903
      Helping HandTeam Member
      Rank: Community Hero

      What’s the text file contain?

    • #33519
      Participant
      Topics: 120
      Replies: 260
      Points: 238
      Rank: Participant

      just the FQDN of domain controllers in the format

      DC1.domain.com,DC2.domain.com,DC3.domain.com

      no spaces, no quotes

    • #33520
      Keymaster
      Topics: 18
      Replies: 4872
      Points: 1,903
      Helping HandTeam Member
      Rank: Community Hero

      That’s why. Your command that works uses regular computer names, so you weren’t comparing apples to apples. But, does the text file contain one computer name per line, or a comma delimited list?

    • #33521
      Keymaster
      Topics: 18
      Replies: 4872
      Points: 1,903
      Helping HandTeam Member
      Rank: Community Hero

      Ah, sorry – you probably put the exact contents.

      So, it doesn’t work because Get-Content reads an entire line of the file at a time. It isn’t parsing comma separated values. So that entire string – all three names, inclusive of commas, is being fed as a single computer name. The book points out that, to make the trick work, you list one computer name PER LINE. GC reads each line at a time and feeds them in.

      And FQDNs would likely work fine. But it’s still an important troubleshooting technique to test apples to apples. Different name resolution techniques come into play with host names vs. FQDNs, right? So if you’re testing, stick with one or the other.

      But in this case, it’s because you have them stacked as a single string. Powershell reads that as one string object. When you’re just in the console, comma separated lists are translated into arrays. They’re not passed as a single string. Confusing, I know. It’s all about thinking objects, not strings.

    • #33522
      Participant
      Topics: 120
      Replies: 260
      Points: 238
      Rank: Participant

      ah I missed the “one computer per line” advise…thank you.

      I do get one returned result but here’s another conundrum.

      I’ve tried running this under Administrator shell (and domain admin as well as Enterprise admin) and I get an access denied error now for rest of computer names. All DC’s in same domain that I’m running from PDC

      Get-WmiObject : Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
      At line:1 char:1

      Is this (Get-WmiObject | (GC)) bordering on remoting, to be seen in later chapters? I’m just trying to run example in the book which I assume is querying more than the local computer I’m logged into. So the access denied is throwing me.

    • #33524
      Participant
      Topics: 120
      Replies: 260
      Points: 238
      Rank: Participant

      Got it working….we had some extra security measures in place and I have sorted it out…thanks for the help re: the .txt file Don

Viewing 6 reply threads
  • The topic ‘PS3 2nd ed; Month of Lunches CH 9 Pipeline deeper’ is closed to new replies.