I have a script that runs the following commands:
$result = Start-Process -Wait -PassThru $proc $args
I want to measure how long it takes. Based on this article, I am trying the following:
$buildtime = measure-command -expression { $result = Start-Process -Wait -PassThru $proc $args }
Unfortunately, it throws the following error:
Start-Process : Cannot validate argument on parameter 'ArgumentList'. The argument is null, empty, or an element of the argument collection contains a null value. Supply a collection that does not contain any null values and then try the command again. At C:\!scripts\pullandbuild.ps1:78 char:90 + ... d -expression { $result = Start-Process -Wait -PassThru $proc $args } + ~~~~~ + CategoryInfo : InvalidData: (:) [Start-Process], ParameterBindingValidationException + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.StartProcessCommand
Due to other issues I had with strings and variable expansion, $args
is defined like this:
$args = @"
& -quit -batchmode -logFile "$logfile" -buildWindows64Player "$($fullpath)\Project.exe"
"@
How can I fix this? Or is there another way to capture the runtime of the script? I'm trying to learn PS so I'd rather avoid just capturing the time before I run it and after I run and comparing, but if that's my only option I will.