Advertisement
Guest User

Untitled

a guest
Dec 1st, 2015
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. Function Prompt {
  2. #get current year
  3. $year = (Get-Date).year
  4. #get a timespan between Christmas for this year and now
  5. $time = [datetime]"25 December $year" - (Get-Date)
  6. #turn the timespan into a string and strip off the milliseconds
  7. $timestring = $time.ToString().Substring(0,10)
  8. #get random string of decorative characters
  9. $front = -join (14,15,42 | Get-Random -Count 2 | Foreach { $_ -as [char] })
  10. $back = -join (14,15,42 | Get-Random -Count 2 | Foreach { $_ -as [char] })
  11. $text="[{0}Christmas in {1}{2}]" -f $front,$timestring,$back
  12. #get each character in the text and randomly assign each a color
  13. $text.tocharArray() | foreach {
  14. $i = Get-Random -Minimum 1 -Maximum 20
  15. Switch ($i) {
  16. {$i -le 20 -and $i -gt 15} { $color = "Red" }
  17. {$i -le 16 -and $i -gt 10} { $color = "Green" }
  18. {$i -le 10 -and $i -gt 5} { $color = "DarkGreen" }
  19. default { $color = "White" }
  20. }
  21. #write each colorized character
  22. Write-Host $_ -nonewline -foregroundcolor $color
  23. } #foreach
  24. #the function needs to write something to the pipeline
  25. Write "PS $($executionContext.SessionState.Path.CurrentLocation)$('>' * ($nestedPromptLevel + 1)) "
  26. } #end function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement