PowerShell: Write Host

Sdílet
Vložit
  • čas přidán 7. 09. 2024
  • Einfache Ausgabe
    Write-Host "Hallo, Welt!"
    Ausgabe mit Farbänderung
    Write-Host "Hallo, Welt!" -ForegroundColor Cyan
    Ausgabe mit Hintergrundfarbänderung
    Write-Host "Hallo, Welt!" -BackgroundColor DarkCyan
    Ausgabe mit Farb- und Hintergrundfarbänderung
    Write-Host "Hallo, Welt!" -ForegroundColor White -BackgroundColor DarkCyan
    Ausgabe von Variablen
    $name = "GitHub Copilot"
    Write-Host "Hallo, $name!"
    Backtick
    Write-Host "Patrick `bGruenauer" # backtick
    Verwendung von `r für Carriage Return
    Write-Host "Hello`rWorld"
    Einfache Ausgabe mit Newline
    Write-Host "Hallo,`nWelt!"
    Funny
    1
    for ($i=0; $i -lt 40; $i++) {
    Write-Host " " -BackgroundColor Green -NoNewline
    Start-Sleep -Milliseconds 10
    }; "`n"
    2
    for ($i=0; $i -lt 40; $i++) {
    Write-Host " " -BackgroundColor Green -NoNewline
    Start-Sleep -Milliseconds 10
    }
    Write-Host "`r" -NoNewline
    for ($i=0; $i -lt 40; $i++) {
    Write-Host " " -BackgroundColor Yellow -NoNewline
    Start-Sleep -Milliseconds 10
    }; "`n"
    3
    for ($color = 1; $color -lt 16; $color++) {
    Write-Host " " -BackgroundColor $color -NoNewline
    Start-Sleep -Milliseconds 10
    }; "`n"
    4
    for ($color = 1; $color -lt 16; $color++) {
    for ($i=0; $i -lt 40; $i++) {
    Write-Host " " -BackgroundColor $color -NoNewline
    Start-Sleep -Milliseconds 10
    }
    Write-Host "`r" -NoNewline
    }; "`n"
    Exkurs: Welche Farben gibt es in PowerShell?
    [enum]::GetValues([System.ConsoleColor])
    [enum]::GetValues([System.ConsoleColor]).value__
    for ($i=1;$i -le 15;$i++) {
    Write-Host "Color for [$i]" -ForegroundColor $i
    }
    www.udemy.com/...

Komentáře •