Get-service -computername () error

by Typeo at 2013-02-05 10:20:49

I am going through the powershell in a month of lunches book and am currently on chapter 7, section 7.3… I ran into an issue and I can seem to get it resolved.

It asked you to run:

Get-service -computername (Get-content C:\names.txt)

To make it as basic as possible, In names.txt it has just one computer name… However, I keep getting this error.

a user uploaded image

Any idea what might be causing this? I am been stuck on it for a while, but cant seem to get it to run…
by DonJ at 2013-02-05 10:33:35
That seems odd indeed. Especially as it works perfectly on my system, right now.

‘localhost’ | Out-File name.txt
Get-Service -comp (gc ./name.txt)

Ran fine.
by Typeo at 2013-02-05 12:20:44
Typed out what you did and it seemed to work… I then changed ./name.txt with ./names.txt and received the same error again. It seems to be something with that one particular text file. I created a new text file with the same content, just a different name and it seemed to work fine. Not sure why it was having issues with the original text file I made.

Either way, it seems to be working fine with the new text file now. Thank you very much for the help!