I'm trying to write a script to check how long it's been since a process was started on a group of 20ish remote machines. I can get the script to output the date correctly, but I'm stuck trying to get it to also tell me the name of the machine that corresponds to the date.
Here's what I have so far:
$ErrorActionPreference = "silentlycontinue"
$computers = Get-Content -path C:\users\mprill\desktop\scripts\dispatchWorkstations.txt # Loads the computers variable with the machines listed in the text file
$output = foreach ($computer in $computers)
write-host Checking $computer
$DateFix = Get-WmiObject -class win32_process -ComputerName $computer | where name -eq 'BrokerService.exe' | select pscomputername,creationdate