January 5, 2016 at 2:55 pm #33517
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.
January 5, 2016 at 3:09 pm #33518
What's the text file contain?
January 5, 2016 at 3:51 pm #33519
just the FQDN of domain controllers in the format
no spaces, no quotes
January 5, 2016 at 3:59 pm #33520
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?
January 5, 2016 at 4:04 pm #33521
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.
January 5, 2016 at 4:47 pm #33522
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.
January 5, 2016 at 5:07 pm #33524
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.