Advertisement
Guest User

Untitled

a guest
Oct 26th, 2016
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.87 KB | None | 0 0
  1. trap {
  2. # handle the error here
  3. }
  4.  
  5. ## Change colors of regular text
  6. $Host.UI.RawUI.BackGroundColor = "DarkMagenta"
  7. $Host.UI.RawUI.ForeGroundColor = "DarkYellow"
  8.  
  9. ## Change colors of special messages (defaults shown)
  10. $Host.PrivateData.DebugBackgroundColor = "Black"
  11. $Host.PrivateData.DebugForegroundColor = "Yellow"
  12. $Host.PrivateData.ErrorBackgroundColor = "Black"
  13. $Host.PrivateData.ErrorForegroundColor = "Red"
  14. $Host.PrivateData.ProgressBackgroundColor = "DarkCyan"
  15. $Host.PrivateData.ProgressForegroundColor = "Yellow"
  16. $Host.PrivateData.VerboseBackgroundColor = "Black"
  17. $Host.PrivateData.VerboseForegroundColor = "Yellow"
  18. $Host.PrivateData.WarningBackgroundColor = "Black"
  19. $Host.PrivateData.WarningForegroundColor = "Yellow"
  20.  
  21. ## Set the format for displaying Exceptions (default shown)
  22. ## Set this to "CategoryView" to get less verbose, more structured output
  23. ## http://blogs.msdn.com/powershell/archive/2006/06/21/641010.aspx
  24. $ErrorView = "NormalView"
  25.  
  26. ## NOTE: This section is only for PowerShell 1.0, it is not used in PowerShell 2.0 and later
  27. ## More control over display of Exceptions (defaults shown), if you want more output
  28. $ReportErrorShowExceptionClass = 0
  29. $ReportErrorShowInnerException = 0
  30. $ReportErrorShowSource = 1
  31. $ReportErrorShowStackTrace = 0
  32.  
  33. ## Set display of special messages (defaults shown)
  34. ## http://blogs.msdn.com/powershell/archive/2006/07/04/Use-of-Preference-Variables-to-control-behavior-of-streams.aspx
  35. ## http://blogs.msdn.com/powershell/archive/2006/12/15/confirmpreference.aspx
  36. $ConfirmPreference = "High"
  37. $DebugPreference = "SilentlyContinue"
  38. $ErrorActionPreference = "Continue"
  39. $ProgressPreference = "Continue"
  40. $VerbosePreference = "SilentlyContinue"
  41. $WarningPreference = "Continue"
  42. $WhatIfPreference = 0
  43.  
  44. $Host.UI.WriteErrorLine("This is an error")
  45.  
  46. $ErrorView = "CategoryView"
  47.  
  48. [PS]> get-item D:blah
  49. ObjectNotFound: (D:blah:String) [Get-Item], ItemNotFoundException
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement