Function HowLong {
<# .Synopsis Returns the time taken to run a command .Description By default returns the time taken to run the last command .Parameter ID The history ID of an earlier item. #>
param ( [Parameter(ValueFromPipeLine=$true)]
$id = ($MyInvocation.HistoryId -1)
)
process { foreach ($i in $id) {
(get-history $i).endexecutiontime.subtract(
(get-history ($i)).startexecutiontime).totalseconds
}
}
}