Processing lists from txt file or others

Welcome Forums General PowerShell Q&A Processing lists from txt file or others

This topic contains 0 replies, has 1 voice, and was last updated by  Forums Archives 7 years, 4 months ago.

  • Author
  • #5821

    Topics: 1562
    Replies: 0
    Points: 0
    Rank: Member

    by Trepidation at 2013-04-18 08:08:31

    I'm looking for a simple tutorial, and I think I am just searching for the wrong words.

    I want to write something to scan certain WMI entries, and then spit them out to a CSV or whatever. I searched around, and I swear I must be using the wrong terms to find it. Somebody has to have posted something to look at memory of a PC, or CPU, or bios revision... etc. I figured if I found something, I could dissect it mentally and figure out a good way to do it. Since I wasn't able to do that, I will ask this:

    If I am writing a script to perform functions on a list provided by a simple text file. What are some really good ways for handling this? Does someone have a link so they don't have to write it all out to me. I know this is kinda ultra basic, most of my stuff tends to be singular in nature so this is new territory.

    by ArtB0514 at 2013-04-18 08:27:46

    What you are looking for is one of the foreach looping processes. Say that your text file has a list of computer names. Then you would want to use one of these methods:

    foreach ($Computer in (Get-Content C:\PathToFile\ComputerNames.txt)) {
    #Peform your task here using $Computer for the -ComputerName property

    Get-Content C:\PathToFile\ComputerNames.txt | foreach-object {
    #Perform your task here using $_ for the -ComputerName property

    The two Get-Help items you need to read for more details are ForEach-Object and about_Foreach.

    by notarat at 2013-04-18 10:30:25

    Jesse Hamrick over at wrote a really nice script to gather WMI information for computers. ... Inv_v2.ps1

    You may want to check it out to see how it gathers information and creates an excel file and places the information into the spreadsheet. I think of it as training in about 40-11 different things I need to learn, lol

The topic ‘Processing lists from txt file or others’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort