August 15, 2017

PowerShell - working with Progress Bar

This PowerShell script generates a number between 0 and 1000000. It calculates an average value, which is surprisingly leading to the middle. SecondsRemaining parameter from Write-Progress cmdlet is reused to show total time used. Additionally CPU load bar is added.

Script output example

August 9, 2017

PowerShell - PSObject property order (ordered hash tables)

How to change property order during PSObject output?

$Properties = @{
 a = 1
 b = 2
 c = 3
$Object = New-Object -TypeName PSObject -Property $Properties
$Object 
c b a
- - -
3 2 1

What if you need a,b and then c property order?