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