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