Forum Discussion
charlie4872
May 03, 2022Brass Contributor
Write-Host AND output results to text file.
Hello I have a script where I want to write results of "offline" hosts to the terminal and also write the results of the offline computers to a .txt file. The code I have below is what I have so far ...
- May 03, 2022
It does a ping/icmp test to the computers listed in the computers.txt file, if the firewall is active.. It won't return the request marking the computer inaccessible. You could try to use Test-Path "\\$($computer)\c$" instead of test-connection -computername.. (Run this as an account who has local admin priviledges on the remote machine, Domain Admin of Global Admin/Device Administator? Also, shouldn't invoke-command -computername (get-content -Path .\computers.txt) be invoke-command -computername $computer ?
charlie4872
May 03, 2022Brass Contributor
Ok Harm it looks like that worked with the Test-Path. For some reason the Test-Connection did not work on any computer. Could be a firewall issue I can look into. I really appreciate your help with this!!
May 03, 2022
No problem, glad to help