File content manipulation using PS 3.0

This topic contains 2 replies, has 3 voices, and was last updated by Profile photo of random commandline random commandline 1 month, 2 weeks ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • #49814
    Profile photo of Aswin Kumar
    Aswin Kumar


    I am trying to fetch content from a .dat file specific to a pattern via powershell 3.0. I would like to get the count of number of "OK" under "STATUS" column(Exactly OK) which is an array. Below is the data for reference.

    Daily Statistics

    ————— ————— ———-
    1300 1998346.21 OK
    156 24949.19 OK
    350 87107.6 OK
    183222 20988447.31 OK
    2255 1042823.8 NOT_OK

    Total Records

    Thanks in advance!!

    Profile photo of Paul Frankovich
    Paul Frankovich

    What have you tried so far? Using Get-Content would be a good start.

    Profile photo of random commandline
    random commandline

    There may be a better way to do this, but this should work.

    $status = Import-Csv "\\path\to\file.dat" -Delimiter ' ' -Header 'arpcount','arpamount','status' | 
    Select-Object -Property @{n='Status';exp={If ($_.status -eq 'OK'){$_.Status}}}
Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.