Quantcast
Channel: PowerShell
Viewing all articles
Browse latest Browse all 15370

getting computernames into cmdlet

$
0
0

I am getting rolling on powershell and wanted to get-eventlog on several computer from one cmdlet.

I have been reading http://windowsitpro.com/blog/getting-computer-names-cmdlet

The example: >Do-Something -computername (Get-Content names.txt)

I put a two workstation hostnames in a txt file named hosts.txt and ran this cmdlet.

get-eventlog -logname system -entrytype error -newest 20 -comp (get-content hosts.txt)

So far so good. My problem is when a hostname in the file can not be reached for some reason, it errors and stops. I get nothing. I want it to just skip the unreachable host and move on to the rest. Hww do I do that?


Viewing all articles
Browse latest Browse all 15370

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>