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?
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.
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.