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

  • Question

  • 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

    Wednesday, October 26, 2016 7:30 PM

Answers

All replies