Link to home
Start Free TrialLog in
Avatar of Blowfelt82
Blowfelt82

asked on

Add row number to data after sort-object has been applied

I have a load of data which I am applying a Sort-Object to, is there a way I can add a row number to the data after the sort. I will be using this to calculate a percentage of the overall work complete...
Avatar of Blowfelt82
Blowfelt82

ASKER

Infact it would also be useful if I could add a column to the data with average run rates etc based on other columns data... If someone could show me roughly how I could acheive that I should be able to work the rest out... Code so far (coutesy of segwig is...)

$total= 5785
'MAC1,'MAC2','MAC3','MAC4' | %{
$path = "\\$_\Z$\TEST\ROUTE"
$mach = $_
Get-ChildItem $path -include ('initialised.txt') -recurse | Select-Object CreationTime, LastWriteTime, @{Name="Machine";Expression={$mach}} , @{Name="Harness";Expression={($_.Directory -Replace ([regex]::Escape("\\$_\Z$\TEST\ROUTE"),""))}}, @{Name="TotalHarnesses";Expression={$total_harnesses}}, @{Name="RunTime";Expression={"{0:N0}" -f ($_.LastWriteTime - $_.CreationTime).TotalMinutes}}| Where-Object {$_.RunTime -gt 0} | Sort-Object CreationTime 
} # | Export-Csv "C:\MachineLoad.txt"

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of footech
footech
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Sorry for the late reply, perfect answer!