Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Add computer name to output

$
0
0

$Computers = get-content "C:\Temp\servers.txt"

Foreach ($Event in $Computers) {Get-Service "Windows Event Log" | Out-File "c:\temp\EventLog.txt"}

 

This code works perfect.  It reads servers.txt and tells me what the state of the service is.  

But the output does not have the computer name.    My output looks like this.

 

Status   Name               DisplayName                           

------   ----               -----------                           

Running  eventlog           Windows Event Log                     

 

How do I add the Computer name to this? We need to find servers that the Eventviewer is not running.

 


Viewing all articles
Browse latest Browse all 6937

Trending Articles