Made format function more flexible
This commit is contained in:
@@ -18,33 +18,43 @@ function Format-Chronometer
|
|||||||
[MonitoredScript[]]
|
[MonitoredScript[]]
|
||||||
$InputObject,
|
$InputObject,
|
||||||
|
|
||||||
|
# This is a ScriptLine object from a MonitoredScript object
|
||||||
|
[Parameter(
|
||||||
|
ValueFromPipeline=$true
|
||||||
|
)]
|
||||||
|
[ScriptLine[]]
|
||||||
|
$Line,
|
||||||
|
|
||||||
# If the average time of a command is more than this, the output is yellow
|
# If the average time of a command is more than this, the output is yellow
|
||||||
[int]
|
[int]
|
||||||
$WarningAt = 20,
|
$WarningAt = 20,
|
||||||
|
|
||||||
#If the average time of a comamand is more than this, the output is red
|
#If the average time of a comamand is more than this, the output is red
|
||||||
[int]
|
[int]
|
||||||
$ErrorAt = 200
|
$ErrorAt = 200,
|
||||||
|
|
||||||
|
# Forces the report to show scripts with no execution time
|
||||||
|
[switch]
|
||||||
|
$ShowAll
|
||||||
)
|
)
|
||||||
|
|
||||||
begin {
|
|
||||||
$green = @{ForgroundColor='green'}
|
|
||||||
$grey = @{ForgroundColor='grey'}
|
|
||||||
$yellow = @{ForgroundColor='grey'}
|
|
||||||
$yellow = @{ForgroundColor='grey'}
|
|
||||||
$yellow = @{ForgroundColor='grey'}
|
|
||||||
}
|
|
||||||
process
|
process
|
||||||
{
|
{
|
||||||
foreach($script in $InputObject)
|
foreach($script in $InputObject)
|
||||||
{
|
{
|
||||||
Write-Host ''
|
if($script.ExecutionTime -ne [TimeSpan]::Zero -or $ShowAll)
|
||||||
Write-Host "Script: $($script.Path)" -ForegroundColor Green
|
{
|
||||||
Write-Host "Execution Time: $($script.ExecutionTime)" -ForegroundColor Green
|
Write-Host ''
|
||||||
foreach($line in $script.line)
|
Write-Host "Script: $($script.Path)" -ForegroundColor Green
|
||||||
{
|
Write-Host "Execution Time: $($script.ExecutionTime)" -ForegroundColor Green
|
||||||
Write-ScriptLine $line -WarningAt $WarningAt -ErrorAt $ErrorAt
|
|
||||||
|
$script.line | Format-Chronometer -WarningAt $WarningAt -ErrorAt $ErrorAt
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach($command in $Line)
|
||||||
|
{
|
||||||
|
Write-ScriptLine $line -WarningAt $WarningAt -ErrorAt $ErrorAt
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user