preform action on each word separated by commas RRS feed

  • Question

  • I have done this before but I have spent an hour on this and I am just frusterated I should be able to do this.  aggg.

    I have a huge list sent to me just like this/

    500, 200032 , 700895, 20008787, ECT, ECT

    It may be 1000's of numbers.  I need to preform a simple action on each number

    I see it is drong.  I have goggled it as I Know this is wrong I cant for the life of me remember what I need to do. 

    so ....

    $numbers = "500, 200032 , 700895, 20008787, ECT, ECT"
    foreach ($number in $numbers) {
    "Do something to $number"
    Please help 


    Monday, August 31, 2015 3:04 PM


  • $numbers = '1,2,3,4,5'
    $numbers -split ',' | ForEach {
        Write-Host "Current number is $_" -ForegroundColor Green

    • Marked as answer by Lishron Monday, August 31, 2015 3:17 PM
    Monday, August 31, 2015 3:09 PM

All replies