Private/Wissen/X_Technology/X82_DiesUndDas.ps1
<#
# Dies und das Alle was sonst nirgends wohin passt - **Hashtags** Übung Musterlösung Backup Sleep Guid - **Version** 2010.11.08 #> # ! Merry Christmas and a Happy New Year (77,101,114,114,121,32,67,104,114,105,115,116,109,97,115,32,97,110,100,32,97,32,72,97,112,112,121,32,78,101,119,32,89,101,97,114 | ForEach-Object {[char][byte]$psitem}) -join '' #region Ein Banner schreiben Function Write-Banner{ <# .SYNOPSIS Creates a banner in large letters and writes to standard output .DESCRIPTION Creates a banner in large letters and writes to standard output .PARAMETER Object Specifies text to return in banner format .INPUTS None. .OUTPUTS None. .EXAMPLE C:\PS> Write-Banner 'HTTP://virot.eu/' .LINK My Blog: http://virot.eu Blog Entry: http://virot.eu/wordpress/the-banner-script Source of shapes: http://ftp3.usa.openbsd.org/pub/OpenBSD/src/usr.sbin/lpr/lpd/lpdchar.c .NOTES Author: Oscar Virot - virot@virot.com Filename: Write-Banner.ps1 #> [CmdletBinding()] Param( [Parameter(Mandatory=$True)] [String] [ValidateScript({if ($_.Length -gt 20) {Throw('Input to long')} else {$true}})] $Object, [Parameter(Mandatory=$False)] [System.ConsoleColor] $ForegroundColor = (Get-Host).UI.RawUI.Foregroundcolor, [Parameter(Mandatory=$False)] [System.ConsoleColor] $BackgroundColor = (Get-Host).UI.RawUI.Backgroundcolor ) Begin { $outputarray = @("","","","","","","","","") $Alphabet = New-Object system.collections.hashtable $Alphabet." " = @(' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ') $Alphabet."!" = @(' !! ', ' !! ', ' !! ', ' !! ', ' !! ', ' ', ' ', ' !! ', ' !! ') $Alphabet."""" = @(' " " ', ' " " ', ' ', ' ', ' ', ' ', ' ', ' ', ' ') $Alphabet."#" = @(' ', ' # # ', ' # # ', ' #######', ' # # ', ' #######', ' # # ', ' # # ', ' ') $Alphabet."$" = @(' $ ', ' $$$$$ ', ' $ $ $', ' $ $ ', ' $$$$$ ', ' $ $', ' $ $ $', ' $$$$$ ', ' $ ') $Alphabet."%" = @(' % ', ' % % %', ' % % ', ' % ', ' % ', ' % ', ' % % ', ' % % %', ' % ') $Alphabet."'" = @(" '' ", " '' ", " ' ", " ' ", " ", " ", " ", " ", " "); $Alphabet."(" = @(' ( ', ' ( ', ' ( ', ' ( ', ' ( ', ' ( ', ' ( ', ' ( ', ' ( ') $Alphabet.")" = @(' ) ', ' ) ', ' ) ', ' ) ', ' ) ', ' ) ', ' ) ', ' ) ', ' ) ') $Alphabet."*" = @(' ', ' * ', ' * * *', ' * * * ', ' *** ', ' * * * ', ' * * *', ' * ', ' ') $Alphabet."+" = @(' ', ' + ', ' + ', ' + ', ' +++++++', ' + ', ' + ', ' + ', ' ') $Alphabet."," = @(' ', ' ', ' ', ' ', ' ,, ', ' ,, ', ' , ', ' , ', ' ') $Alphabet."-" = @(' ', ' ', ' ', ' ', ' -------', ' ', ' ', ' ', ' ') $Alphabet."." = @(' ', ' ', ' ', ' ', ' ', ' ', ' ', ' .. ', ' .. ') $Alphabet."/" = @(' ', ' /', ' / ', ' / ', ' / ', ' / ', ' / ', ' / ', ' ') $Alphabet."0" = @(' 00000 ', ' 0 0', ' 0 00', ' 0 0 0', ' 0 0 0', ' 0 0 0', ' 00 0', ' 0 0', ' 00000 ') $Alphabet."1" = @(' 1 ', ' 11 ', ' 1 1 ', ' 1 ', ' 1 ', ' 1 ', ' 1 ', ' 1 ', ' 11111 ') $Alphabet."2" = @(' 22222 ', ' 2 2', ' 2', ' 2 ', ' 222 ', ' 2 ', ' 2 ', ' 2 ', ' 2222222') $Alphabet."3" = @(' 33333 ', ' 3 3', ' 3', ' 3', ' 3333 ', ' 3', ' 3', ' 3 3', ' 33333 ') $Alphabet."4" = @(' 4 ', ' 44 ', ' 4 4 ', ' 4 4 ', ' 4 4 ', ' 4 4 ', ' 4444444', ' 4 ', ' 4 ') $Alphabet."5" = @(' 5555555', ' 5 ', ' 5 ', ' 55555 ', ' 5 ', ' 5', ' 5', ' 5 5 ', ' 5555 ') $Alphabet."6" = @(' 6666 ', ' 6 ', ' 6 ', ' 6 ', ' 6 6666 ', ' 66 6', ' 6 6', ' 6 6', ' 66666 ') $Alphabet."7" = @(' 7777777', ' 7 7', ' 7 ', ' 7 ', ' 7 ', ' 7 ', ' 7 ', ' 7 ', ' 7 ') $Alphabet."8" = @(' 88888 ', ' 8 8', ' 8 8', ' 8 8', ' 88888 ', ' 8 8', ' 8 8', ' 8 8', ' 88888 ') $Alphabet."9" = @(' 99999 ', ' 9 9', ' 9 9', ' 9 9', ' 999999', ' 9', ' 9', ' 9 9', ' 9999 ') $Alphabet.":" = @(' ', ' ', ' ', ' :: ', ' :: ', ' ', ' ', ' :: ', ' :: ') $Alphabet.";" = @(' ;; ', ' ;; ', ' ', ' ', ' ;; ', ' ;; ', ' ; ', ' ; ', ' ') $Alphabet."=" = @(' ', ' ', ' ', ' =======', ' ', ' =======', ' ', ' ', ' ') $Alphabet."?" = @(' ???? ', ' ? ?', ' ? ?', ' ?', ' ?? ', ' ? ', ' ? ', ' ', ' ? ') $Alphabet."@" = @(' @@@@ ', ' @ @', ' @ @@ @', ' @ @ @ @', ' @ @ @ @', ' @ @@@@ ', ' @ ', ' @ @', ' @@@@ ') $Alphabet."A" = @(' AAA ', ' A A ', ' A A', ' A A', ' AAAAAAA', ' A A', ' A A', ' A A', ' A A') $Alphabet."B" = @(' BBBBBB ', ' B B', ' B B', ' B B', ' BBBBB ', ' B B', ' B B', ' B B', ' BBBBBB ') $Alphabet."C" = @(' CCCC ', ' C C', ' C ', ' C ', ' C ', ' C ', ' C ', ' C C', ' CCCC ') $Alphabet."D" = @(' DDDDD ', ' D D ', ' D D', ' D D', ' D D', ' D D', ' D D', ' D D ', ' DDDDD ') $Alphabet."E" = @(' EEEEEEE', ' E ', ' E ', ' E ', ' EEEEEE ', ' E ', ' E ', ' E ', ' EEEEEEE') $Alphabet."F" = @(' FFFFFFF', ' F ', ' F ', ' F ', ' FFFFFF ', ' F ', ' F ', ' F ', ' F ') $Alphabet."G" = @(' GGGG ', ' G G', ' G ', ' G ', ' G ', ' G GGGG', ' G G', ' G G', ' GGGG ') $Alphabet."H" = @(' H H', ' H H', ' H H', ' H H', ' HHHHHHH', ' H H', ' H H', ' H H', ' H H') $Alphabet."I" = @(' IIIII ', ' I ', ' I ', ' I ', ' I ', ' I ', ' I ', ' I ', ' IIIII ') $Alphabet."J" = @(' JJJJJ', ' J ', ' J ', ' J ', ' J ', ' J ', ' J ', ' J J ', ' JJJ ') $Alphabet."K" = @(' K K', ' K K ', ' K K ', ' K K ', ' K K ', ' KK K ', ' K K ', ' K K ', ' K K') $Alphabet."L" = @(' L ', ' L ', ' L ', ' L ', ' L ', ' L ', ' L ', ' L ', ' LLLLLLL') $Alphabet."M" = @(' M M', ' MM MM', ' M M M M', ' M M M', ' M M', ' M M', ' M M', ' M M', ' M M') $Alphabet."N" = @(' N N', ' NN N', ' N N N', ' N N N', ' N N N', ' N NN', ' N N', ' N N', ' N N') $Alphabet."O" = @(' OOO ', ' O O ', ' O O', ' O O', ' O O', ' O O', ' O O', ' O O ', ' OOO ') $Alphabet."P" = @(' PPPPPP ', ' P P', ' P P', ' P P', ' PPPPPP ', ' P ', ' P ', ' P ', ' P ') $Alphabet."Q" = @(' QQQ ', ' Q Q ', ' Q Q', ' Q Q', ' Q Q', ' Q Q Q', ' Q Q Q', ' Q Q ', ' QQQ Q') $Alphabet."R" = @(' RRRRRR ', ' R R', ' R R', ' R R', ' RRRRRR ', ' R R ', ' R R ', ' R R ', ' R R') $Alphabet."S" = @(' SSSSS ', ' S S', ' S ', ' S ', ' SSSSS ', ' S', ' S', ' S S', ' SSSSS ') $Alphabet."T" = @(' TTTTTTT', ' T ', ' T ', ' T ', ' T ', ' T ', ' T ', ' T ', ' T ') $Alphabet."U" = @(' U U', ' U U', ' U U', ' U U', ' U U', ' U U', ' U U', ' U U', ' UUUUU ') $Alphabet."V" = @(' V V', ' V V', ' V V', ' V V ', ' V V ', ' V V ', ' V V ', ' V ', ' V ') $Alphabet."W" = @(' W W', ' W W', ' W W', ' W W', ' W W W', ' W W W', ' W W W W', ' WW WW', ' W W') $Alphabet."X" = @(' X X', ' X X', ' X X ', ' X X ', ' X ', ' X X ', ' X X ', ' X X', ' X X') $Alphabet."Y" = @(' Y Y', ' Y Y', ' Y Y ', ' Y Y ', ' Y ', ' Y ', ' Y ', ' Y ', ' Y ') $Alphabet."Z" = @(' ZZZZZZZ', ' Z', ' Z ', ' Z ', ' Z ', ' Z ', ' Z ', ' Z ', ' ZZZZZZZ') $Alphabet."�" = @(' ��� ', ' � � ', ' ��� ', ' � � ', ' � �', ' �������', ' � �', ' � �', ' � �') $Alphabet."�" = @(' � �', ' ��� ', ' � � ', ' � �', ' � �', ' �������', ' � �', ' � �', ' � �') $Alphabet."�" = @(' � �', ' ��� ', ' � � ', ' � �', ' � �', ' � �', ' � �', ' � � ', ' ��� ') $Alphabet."[" = @(' [[[[ ', ' [ ', ' [ ', ' [ ', ' [ ', ' [ ', ' [ ', ' [ ', ' [[[[ ') $Alphabet."\" = @(' ', ' \ ', ' \ ', ' \ ', ' \ ', ' \ ', ' \ ', ' \', ' ') $Alphabet."]" = @(' ]]]] ', ' ] ', ' ] ', ' ] ', ' ] ', ' ] ', ' ] ', ' ] ', ' ]]]] ') $Alphabet." " = @(' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ') <# $Alphabet."`" = @(' `` ', ' `` ', ' ` ', ' ` ', ' ', ' ', ' ', ' ', ' ') #> $Alphabet."a" = @(' ', ' ', ' ', ' aaaa ', ' a ', ' aaaaa ', ' a a', ' a aa', ' aaaa a') $Alphabet."b" = @(' b ', ' b ', ' b ', ' b bbb ', ' bb b ', ' b b', ' b b', ' bb b ', ' b bbb ') $Alphabet."c" = @(' ', ' ', ' ', ' cccc ', ' c c ', ' c ', ' c ', ' c c ', ' cccc ') $Alphabet."d" = @(' d ', ' d ', ' d ', ' ddd d ', ' d dd ', ' d d ', ' d d ', ' d dd ', ' ddd d ') $Alphabet."e" = @(' ', ' ', ' ', ' eeee ', ' e e ', ' eeeeee ', ' e ', ' e e ', ' eeee ') $Alphabet."f" = @(' ff ', ' f f ', ' f ', ' f ', ' fffff ', ' f ', ' f ', ' f ', ' f ') $Alphabet."g" = @(' ggg g ', ' g gg ', ' g g ', ' g g ', ' g gg ', ' ggg g ', ' g ', ' g g ', ' gggg ') $Alphabet."h" = @(' h ', ' h ', ' h ', ' h hhh ', ' hh h ', ' h h ', ' h h ', ' h h ', ' h h ') $Alphabet."i" = @(' ', ' i ', ' ', ' ii ', ' i ', ' i ', ' i ', ' i ', ' iii ') $Alphabet."j" = @(' jj ', ' j ', ' j ', ' j ', ' j ', ' j ', ' j ', ' j j ', ' jjj ') $Alphabet."k" = @(' k ', ' k ', ' k ', ' k k ', ' k k ', ' k k ', ' kk k ', ' k k ', ' k k ') $Alphabet."l" = @(' ll ', ' l ', ' l ', ' l ', ' l ', ' l ', ' l ', ' l ', ' lll ') $Alphabet."m" = @(' ', ' ', ' ', ' m m mm ', ' mm m m', ' m m m', ' m m m', ' m m m', ' m m m') $Alphabet."n" = @(' ', ' ', ' ', ' n nnn ', ' nn n ', ' n n ', ' n n ', ' n n ', ' n n ') $Alphabet."o" = @(' ', ' ', ' ', ' oooo ', ' o o ', ' o o ', ' o o ', ' o o ', ' oooo ') $Alphabet."p" = @(' p ppp ', ' pp p ', ' p p ', ' p p ', ' pp p ', ' p ppp ', ' p ', ' p ', ' p ') $Alphabet."q" = @(' qqq q ', ' q qq ', ' q q ', ' q q ', ' q qq ', ' qqq q ', ' q ', ' q ', ' q ') $Alphabet."r" = @(' ', ' ', ' ', ' r rrr ', ' rr r ', ' r ', ' r ', ' r ', ' r ') $Alphabet."s" = @(' ', ' ', ' ', ' ssss ', ' s s ', ' ss ', ' ss ', ' s s ', ' ssss ') $Alphabet."t" = @(' ', ' t ', ' t ', ' ttttt ', ' t ', ' t ', ' t ', ' t t ', ' tt ') $Alphabet."u" = @(' ', ' ', ' ', ' u u ', ' u u ', ' u u ', ' u u ', ' u uu ', ' uuu u ') $Alphabet."v" = @(' ', ' ', ' ', ' v v', ' v v', ' v v', ' v v ', ' v v ', ' v ') $Alphabet."w" = @(' ', ' ', ' ', ' w w', ' w w w', ' w w w', ' w w w', ' w w w', ' ww ww ') $Alphabet."x" = @(' ', ' ', ' ', ' x x ', ' x x ', ' xx ', ' xx ', ' x x ', ' x x ') $Alphabet."y" = @(' y y ', ' y y ', ' y y ', ' y y ', ' y yy ', ' yyy y ', ' y ', ' y y ', ' yyyy ') $Alphabet."z" = @(' ', ' ', ' ', ' zzzzzz ', ' z ', ' z ', ' z ', ' z ', ' zzzzzz ') $Alphabet."}" = @(' }} ', ' } ', ' } ', ' } ', ' } ', ' } ', ' } ', ' } ', ' }} ') $Alphabet."|" = @(' | ', ' | ', ' | ', ' | ', ' | ', ' | ', ' | ', ' | ', ' | ') $Alphabet."}" = @(' }} ', ' } ', ' } ', ' } ', ' } ', ' } ', ' } ', ' } ', ' }} ') $Alphabet."~" = @(' ~~ ', ' ~ ~ ~', ' ~~ ', ' ', ' ', ' ', ' ', ' ', ' ') } Process { ForEach($char in $Object[0..($Object.length-1)]) { if ($Null -ne $Alphabet[[string]$char]) { ForEach($i in 0..8) { $outputarray[$i] += $Alphabet[[string]$char][$i] } } } ForEach($i in 0..8) { Write-Host -Object $outputarray[$i] -Foregroundcolor:$Foregroundcolor -Backgroundcolor:$Backgroundcolor } } } Write-Banner "Hallo Wuerzburg!" #endregion #region Chat-System function Enter-Chat { param( [Parameter(Mandatory)] [string]$ChatChannelName, [string]$Name = $env:USERNAME, [Switch]$ShowOldPosts, [string]$HomeShare ) if ($ShowOldPosts) { $Option = '' } else { $Option = '-Tail 0' } $Path = Join-Path -Path $HomeShare -ChildPath "$ChatChannelName.txt" $exists = Test-Path -Path $Path if ($exists -eq $false) { $null = New-Item -Path $Path -Force -ItemType File } $process = Start-Process -FilePath powershell -ArgumentList "-noprofile -windowstyle hidden -command Get-Content -Path '$Path' $Option -Wait | Out-GridView -Title 'Chat: [$ChatChannelName]'" -PassThru Write-Host "To exit, enter: quit" "[$Name entered the chat]" | Add-Content -Path $Path do { Write-Host "[$ChatChannelName]: " -ForegroundColor Green -NoNewline $inputText = Read-Host $isStopCommand = 'quit','exit','stop','leave' -contains $inputText if ($isStopCommand -eq $false) { "[$Name] $inputText" | Add-Content -Path $Path } } until ($isStopCommand -eq $true) "[$Name left the chat]" | Add-Content -Path $Path $process | Stop-Process } function Get-ChatChannel { param($HomeShare) Get-ChildItem -Path $HomeShare -Filter *.txt -File | ForEach-Object { [PSCustomObject]@{ ChannelName = [System.IO.Path]::GetFileNameWithoutExtension($_.Name) LastActive = $_.LastWriteTime Started = $_.CreationTime } } } #endregion #region Eine Anzahl an Sekunden warten Start-Sleep -Seconds 3 #endregion #region Eine eindeutige Id erstellen # z.B. für Dateinamen, Primärschlüssel, ... New-Guid | Select-Object -ExpandProperty Guid #endregion |