Skip to content

get_percent_bar $percentage: Cannot validate argument on parameter 'percent' #181

@aetonsi

Description

@aetonsi

Hi,
i'm having the error mentioned when invoking winfetch the first time after each boot. Afterwards, it works just fine.

I have created a small function to invoke winfetch with my preferred parameters:

function Show-Winfetch([switch] $Short) {
  if ($Short) {
    $params = @{
      showpkgs = ''
    }
  } else {
    $params = @{
      all       = $true
      showdisks = @('*')
      showpkgs  = @('scoop', 'choco')
    }
  }
  & winfetch @params -blink -memorystyle textbar -cpustyle textbar -diskstyle textbar -batterystyle textbar
}

Then i simply call Show-Winfetch in one of my startup scripts.
It prints this:

 lllllllllllllll   lllllllllllllll  user@COMPUTERNAME
 lllllllllllllll   lllllllllllllll  -------------
 lllllllllllllll   lllllllllllllll  OS: Windows 11 Pro N
 lllllllllllllll   lllllllllllllll  Host: HP HP Pavilion
 lllllllllllllll   lllllllllllllll  Kernel: 10.0.22621.0
 lllllllllllllll   lllllllllllllll  Motherboard: HP 87C5
 lllllllllllllll   lllllllllllllll  Uptime: 1 minute
                                    Resolution: 1536x864
 lllllllllllllll   lllllllllllllll  PS Packages: 4 Module
 lllllllllllllll   lllllllllllllll  Packages: 105 (choco)
 lllllllllllllll   lllllllllllllll  Shell: PowerShell v7.
 lllllllllllllll   lllllllllllllll  Terminal: Windows Ter
 lllllllllllllll   lllllllllllllll  Theme: Custom (System
 lllllllllllllll   lllllllllllllll  CPU: AMD Ryzen 5 4500
 lllllllllllllll   lllllllllllllll  GPU: AMD Radeon(TM) G
get_percent_bar : Cannot validate argument on parameter 'percent'. The 119 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 C:\tools\winfetch\winfetch.ps1:327 char:53
+         'textbar' { return "$text $(get_percent_bar $percentage)" }
+                                                     ~~~~~~~~~~~
+ CategoryInfo          : InvalidData: (:) [get_percent_bar], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,get_percent_bar
                                    CPU Usage: 299 proces
                                    Memory: 7.67 GiB / 19
                                    Disk (C:): 309 GiB /
                                    Disk (K:): 3 GiB / 15
                                    Disk (L:): 317 GiB /
                                    Battery: Discharging,
                                    Locale: Italy - Engli
                                    Weather: 6°C - Overca
                                    Local IP: 192.168.178
                                    Public IP: 99.17.56.1

The output is truncated like that because i am running the script inside a Windows Terminal split pane ($Host.UI.RawUI.WindowSize.Width = 58, $Host.UI.RawUI.WindowSize.Height = 30)


thank you for your time

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions