Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

How can I execute a command on every line in a text file?

$
0
0

I've been using a small powershell script to check remote computers for installed software:

    $pc = Read-Host -Prompt 'Which PC would you like to check?'
    gwmi win32_product -ComputerName $pc > $("" + $pc + ".txt")

This has been great for a one-at-a-time solution.  What i'd like to do is instead of getting $pc from user input, i'd like to have all of the computers that need checking listed in a text file and execute the command using each line as the $pc variable.

I'm terrible at loops, so I'm seeking some help.

Thanks in advance


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>