One liner works fine from my server to a remote computer. I want to take my one liner and convert it to a ForEach loop. I want to loop through all the computers in my environment.
One liner:
Write-output (Get-ChildItem '\\mycomputer\C$\Program Files\OSC\LogGen\LOGS').Count
ForEach attempt (not working) foreach loop through list of computers and return count results for each computer in list.
$computerlist = gc "D:\computerlist.txt"
ForEach ($host in $computerlist) {
Write-Output (Get-ChildItem "\\$host\C$\Program Files\LOGS").Count
}