microsoft / DSCParser

Allows the conversion of DSC scripts into PSObject for analysis purposes
MIT License
29 stars 20 forks source link

ValidationMetadataException: The 101 argument is greater than the maximum allowed range of 100 #46

Closed slaurentpco closed 7 months ago

slaurentpco commented 7 months ago

With 2.0.0.3 I sometimes have this issue:

    ValidationMetadataException: The 101 argument is greater than the maximum allowed range of 100. Supply an argument that is less than or equal to 100 and then try the 
command again.
    ParameterBindingValidationException: Cannot validate argument on parameter 'PercentComplete'. The 101 argument is greater than the maximum allowed range of 100. Supply an argument that is less than or equal to 100 and then try the command again.
    at Update-DSCResultWithMetadata, C:\repos\mpc\mpc-psu-config\modules\PicM365DSC\output\RequiredModules\DSCParser\2.0.0.3\Modules\DSCParser.psm1:26
    at ConvertTo-DSCObject, C:\repos\mpc\mpc-psu-config\modules\PicM365DSC\output\RequiredModules\DSCParser\2.0.0.3\Modules\DSCParser.psm1:535
...

By looking at the code

 for ($i = $tokenPositionOfNode; $i -le $tokens.Length; $i++)
    {
        $percent = ($i / ($tokens.Length - $tokenPositionOfNode) * 100)
        Write-Progress -Status "Processing $percent%" `
                       -Activity "Parsing Comments" `
                       -PercentComplete $percent

If I'm not mistaken when $i is equal to $tokens.Length then $percent is greater than 100