Skip to content

Instantly share code, notes, and snippets.

@marcoandre1
Last active October 4, 2019 18:32
Show Gist options
  • Save marcoandre1/fbc98fa4208cec71df0765b290e6c553 to your computer and use it in GitHub Desktop.
Save marcoandre1/fbc98fa4208cec71df0765b290e6c553 to your computer and use it in GitHub Desktop.

More info Write-Host

To stop script, simply press Ctrl + C

for (;;)
{
    [uint32] $num1 = Get-Random -Count 1 -InputObject (100..999)
    [uint32] $num2 = Get-Random -Count 1 -InputObject (100..999)
    [uint32] $num3 = Get-Random -Count 1 -InputObject (100..999)
    [uint32] $num4 = Get-Random -Count 1 -InputObject (100..999)
    [uint32] $num5 = Get-Random -Count 1 -InputObject (100..999)
    [uint32] $num6 = Get-Random -Count 1 -InputObject (100..999)
    [uint32] $num7 = Get-Random -Count 1 -InputObject (100..999)
    [uint32] $num8 = Get-Random -Count 1 -InputObject (100..999)
    [uint32] $num9 = Get-Random -Count 1 -InputObject (100..999)
    [uint32] $num10 = Get-Random -Count 1 -InputObject (100..999)
    [uint32] $num11 = Get-Random -Count 1 -InputObject (100..999)
    [uint32] $num12 = Get-Random -Count 1 -InputObject (100..999)
    [uint32] $num13 = Get-Random -Count 1 -InputObject (100..999)
    [uint32] $num14 = Get-Random -Count 1 -InputObject (100..999)
    [uint32] $num15 = Get-Random -Count 1 -InputObject (100..999)
    [uint32] $num16 = Get-Random -Count 1 -InputObject (100..999)
    Write-Host $num1' ' -NoNewline -ForegroundColor Black
    Write-Host $num2' ' -NoNewline -ForegroundColor DarkBlue
    Write-Host $num3' ' -NoNewline -ForegroundColor DarkGreen
    Write-Host $num4' ' -NoNewline -ForegroundColor DarkCyan
    Write-Host $num5' ' -NoNewline -ForegroundColor DarkRed
    Write-Host $num6' ' -NoNewline -ForegroundColor DarkMagenta
    Write-Host $num7' ' -NoNewline -ForegroundColor DarkYellow
    Write-Host $num8' ' -NoNewline -ForegroundColor Gray
    Write-Host $num9' ' -NoNewline -ForegroundColor DarkGray
    Write-Host $num10' ' -NoNewline -ForegroundColor Blue
    Write-Host $num11' ' -NoNewline -ForegroundColor Green
    Write-Host $num12' ' -NoNewline -ForegroundColor Cyan
    Write-Host $num13' ' -NoNewline -ForegroundColor Red
    Write-Host $num14' ' -NoNewline -ForegroundColor Magenta
    Write-Host $num15' ' -NoNewline -ForegroundColor Yellow
    Write-Host $num16 -ForegroundColor White
}

More elegant way but without colors. Stop script with Ctrl + C

for (;;)
{
    [uint32] $num1 = Get-Random -Count 1 -InputObject (100..999)
    [uint32] $num2 = Get-Random -Count 1 -InputObject (100..999)
    [uint32] $num3 = Get-Random -Count 1 -InputObject (100..999)
    [uint32] $num4 = Get-Random -Count 1 -InputObject (100..999)
    [uint32] $num5 = Get-Random -Count 1 -InputObject (100..999)
    [uint32] $num6 = Get-Random -Count 1 -InputObject (100..999)
    [uint32] $num7 = Get-Random -Count 1 -InputObject (100..999)
    [uint32] $num8 = Get-Random -Count 1 -InputObject (100..999)
    [uint32] $num9 = Get-Random -Count 1 -InputObject (100..999)
    [uint32] $num10 = Get-Random -Count 1 -InputObject (100..999)
    [uint32] $num11 = Get-Random -Count 1 -InputObject (100..999)
    [uint32] $num12 = Get-Random -Count 1 -InputObject (100..999)
    [uint32] $num13 = Get-Random -Count 1 -InputObject (100..999)
    [uint32] $num14 = Get-Random -Count 1 -InputObject (100..999)
    [uint32] $num15 = Get-Random -Count 1 -InputObject (100..999)
    [uint32] $num16 = Get-Random -Count 1 -InputObject (100..999)
    Write-Host ($num1, $num2, $num3, $num4, $num5, $num6, $num7, $num8, $num9, $num10, $num11, $num12, $num13, $num14, $num15, $num16) -Separator " "
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment