2017年12月24日

【PowerShell】クリスマスツリーを作ってみた


今日は12月24日、クリスマスイブということでスクリプトでクリスマスツリーを作ってみました。

################################################################################
# ChristmasTree.ps1
################################################################################
for($i = 0; $i -lt 10; $i++)
{
    cls
    Write-Host "   Merry Christmas   " -ForegroundColor Red -BackgroundColor Green
    Write-Host ""

    $mod = $i % 2

    if ($mod -eq 0)
    {
        Write-Host "          ☆" -ForegroundColor Yellow
        Write-Host ""
        Write-Host "        *" -NoNewline -ForegroundColor Red
        Write-Host "   *" -ForegroundColor Green
        Write-Host ""
        Write-Host "      *" -NoNewline -ForegroundColor Red
        Write-Host "   *" -NoNewline -ForegroundColor Green
        Write-Host "   *" -ForegroundColor Yellow
        Write-Host ""
        Write-Host "    *" -NoNewline -ForegroundColor Yellow
        Write-Host "   *" -NoNewline -ForegroundColor Red
        Write-Host "   *" -NoNewline -ForegroundColor Green
        Write-Host "   *" -ForegroundColor Red
        Write-Host ""
        Write-Host "  *" -NoNewline -ForegroundColor Green
        Write-Host "   *" -NoNewline -ForegroundColor Red
        Write-Host "   *" -NoNewline -ForegroundColor Green
        Write-Host "   *" -NoNewline -ForegroundColor Red
        Write-Host "   *" -ForegroundColor Yellow
        Write-Host "          ||" -ForegroundColor DarkRed
        Write-Host "          ||" -ForegroundColor DarkRed
        Write-Host ""
    }
    else
    {
        Write-Host "          ☆" -ForegroundColor Yellow
        Write-Host ""
        Write-Host "        *" -NoNewline -ForegroundColor Green
        Write-Host "   *" -ForegroundColor Yellow
        Write-Host ""
        Write-Host "      *" -NoNewline -ForegroundColor Yellow
        Write-Host "   *" -NoNewline -ForegroundColor Red
        Write-Host "   *" -ForegroundColor Green
        Write-Host ""
        Write-Host "    *" -NoNewline -ForegroundColor Red
        Write-Host "   *" -NoNewline -ForegroundColor Green
        Write-Host "   *" -NoNewline -ForegroundColor Yellow
        Write-Host "   *" -ForegroundColor Green
        Write-Host ""
        Write-Host "  *" -NoNewline -ForegroundColor Yellow
        Write-Host "   *" -NoNewline -ForegroundColor Green
        Write-Host "   *" -NoNewline -ForegroundColor Yellow
        Write-Host "   *" -NoNewline -ForegroundColor Green
        Write-Host "   *" -ForegroundColor Red
        Write-Host "          ||" -ForegroundColor DarkRed
        Write-Host "          ||" -ForegroundColor DarkRed
        Write-Host ""
    }

    Start-Sleep -m 1000
}
なんかものずごい力技!(汗)


実行結果


それではよいクリスマスを。







スポンサーリンク