< Back

New-PercentBar

Sat Jan 18, 2020 8:23 pm

NAME New-PercentBar



SYNOPSIS

Creates a new Percentage Bar.





SYNTAX

New-PercentBar [-Percent] <Decimal> [-BarCharacter <Char>] [-RemainderCharacter <Char>] [-LeadingCharacter <Char>]

[-Length <Int32>] [-Border <String>] [<CommonParameters>]



New-PercentBar [-Percent] <Decimal> [-BarCharacter <Char>] [-RemainderCharacter <Char>] [-LeadingCharacter <Char>]

[-Length <Int32>] -NoBorder [<CommonParameters>]





DESCRIPTION

The New-PercentBar cmdlet creates a new Percentage Bar, a visual representation of an quanity out of 100.



The percentage bar is returned as a string with a border. The borderer can be excluded if desired.





PARAMETERS

-Percent <Decimal>



Required? true

Position? 1

Default value 0

Accept pipeline input? true (ByValue, ByPropertyName)

Accept wildcard characters? false



-BarCharacter <Char>



Required? false

Position? named

Default value x

Accept pipeline input? false

Accept wildcard characters? false



-RemainderCharacter <Char>



Required? false

Position? named

Default value .

Accept pipeline input? false

Accept wildcard characters? false



-LeadingCharacter <Char>



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Length <Int32>



Required? false

Position? named

Default value 10

Accept pipeline input? false

Accept wildcard characters? false



-Border <String>



Required? false

Position? named

Default value []

Accept pipeline input? false

Accept wildcard characters? false



-NoBorder [<SwitchParameter>]



Required? true

Position? named

Default value False

Accept pipeline input? false

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS

System.Decimal





OUTPUTS

System.String





-------------------------- EXAMPLE 1 --------------------------



PS C:\\>New-PercentBar -Percent 0.5



This example generates a Percentage Bar that is 50% filled, with a default square bracket border:



[xxxxx.....]









-------------------------- EXAMPLE 2 --------------------------



PS C:\\>New-PercentBar -Percent 0.3 -Border '||'



This example generates a Percentage Bar that is 30% filled, with a border constructed out of pipe (|) characters:



|xxx.......|









-------------------------- EXAMPLE 3 --------------------------



PS C:\\>0.8 | New-PercentBar -NoBorder



This example takes a decimal value from the pipeline and generates a Percentage Bar that is 80% filled and doesn't

have a border:



xxxxxxxx..









-------------------------- EXAMPLE 4 --------------------------



PS C:\\>New-PercentBar -Percent 0.8 -BarCharacter '-' -RemainderCharacter ' '



This example uses customized characters:



[-------- ]









-------------------------- EXAMPLE 5 --------------------------



PS C:\\>New-PercentBar -Percent 0.2 -Length 20



This example is twice as long as the default percentage bar:



[xxxx................]









-------------------------- EXAMPLE 6 --------------------------



PS C:\\>Get-WmiObject Win32_LogicalDisk | Select-Object -Property DeviceID, VolumeName, Size, @{N = 'Used'; E = {1

- ($_.FreeSpace / $_.Size) | New-PercentBar}}



This example displays the Disk Letter, Label, Size and a Percent Bar prepresenting the freespace of all disks on

the local system.



DeviceID VolumeName Size Used

-------- ---------- ---- ----

C: OS 499512242176 [x.........]

D: Games 320070479872 [xxxxx.....]

M: MEDIA 1500299390976 [xxxxxxx...]











RELATED LINKS

https://github.com/Windos/PoshPctBar