mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-03-31 11:16:12 +02:00
Update write-code.ps1
This commit is contained in:
parent
b349cd3416
commit
0a5cb95651
@ -3,8 +3,10 @@
|
||||
Writes code
|
||||
.DESCRIPTION
|
||||
This PowerShell script generates and writes PowerShell code on the console (for fun).
|
||||
.PARAMETER color
|
||||
Specifies the color to use ("green" by default)
|
||||
.PARAMETER speed
|
||||
Specifies the speed in milliseconds per code line
|
||||
Specifies the speed in milliseconds per code line (500 by default)
|
||||
.EXAMPLE
|
||||
PS> ./write-code
|
||||
.LINK
|
||||
@ -13,7 +15,7 @@
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
param([int]$Speed = 500) # milliseconds
|
||||
param([string]$color = "green", [int]$speed = 500) # milliseconds
|
||||
|
||||
function GetRandomCodeLine {
|
||||
$Generator = New-Object System.Random
|
||||
@ -47,10 +49,10 @@ function GetRandomCodeLine {
|
||||
}
|
||||
|
||||
try {
|
||||
Write-Host -foreground green "try {"
|
||||
Write-Host -foreground $color "try {"
|
||||
while ($true) {
|
||||
Write-Host -foreground green "$(GetRandomCodeLine)"
|
||||
Start-Sleep -milliseconds $Speed
|
||||
Write-Host -foreground $color "$(GetRandomCodeLine)"
|
||||
Start-Sleep -milliseconds $speed
|
||||
}
|
||||
exit 0 # success
|
||||
} catch {
|
||||
|
Loading…
Reference in New Issue
Block a user