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

This topic contains 6 replies, has 2 voices, and was last updated by  Jeff Taylor 2 years, 6 months ago.

  • Author
  • #33517

    Jeff Taylor

    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

    Don Jones

    What's the text file contain?

  • #33519

    Jeff Taylor

    just the FQDN of domain controllers in the format,,

    no spaces, no quotes

  • #33520

    Don Jones

    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

    Don Jones

    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

    Jeff Taylor

    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

    Jeff Taylor

    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

You must be logged in to reply to this topic.