Sorting in Powershell

  • hi,

    i am using powershell to get the output

    I am planning implement sorting to my output.below is the format I am writing my objects to html file.

    I want sort the object of lastrunoutocome field.

    can anyone suggest please

    foreach($item in $sqlServer.JobServer.Jobs)

    {

    Write-Host $sqlserver $item.name $item.OwnerLoginName $item.IsEnabled $item.LastRunDate $item.LastRunOutcome

    writeDiskInfo $ServiceFileName $sqlServer $item.name $item.OwnerLoginName

    }

  • foreach($item in $sqlServer.JobServer.Jobs)

    {

    Write-Host $sqlserver $item.name $item.OwnerLoginName $item.IsEnabled $item.LastRunDate $item.LastRunOutcome

    writeDiskInfo $ServiceFileName $sqlServer $item.name $item.OwnerLoginName

    }

    I don't see anywhere in this that you are writing to HTML, also what does "writeDiskInfo" command do with the values you are passing into it?

    You can use "sort-object" through the pipeline to sort the objects before piping to an output.

    Shawn Melton
    Twitter: @wsmelton
    Blog: wsmelton.github.com
    Github: wsmelton

  • I guess my question would be... why on Earth are you doing this in PowerShell?

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply