Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <#
- # PowerShell Console Logging function
- # [parameters]
- # @type {string} defines the type of the message. Can be success,information, warning, error or empty.
- # @message {string} your log message
- # [notes]
- # Make sure that $verbose is set to $true, otherwise, it won't output anything.
- # [examples]
- # Console-ShowMessage "information" "Operation started"
- # Console-ShowMessage "success" "Operation finished succesful!"
- # Console-ShowMessage "warning" "Problems have been found..."
- # Console-ShowMessage "error" "Operation has failed!"
- # Console-ShowMessage -message "I'm just a simple log message"
- #>
- function Console-ShowMessage([string]$type,$message){
- if($verbose){
- Write-Host ("[{0}] " -f (Get-Date)) -NoNewline;
- switch ($type){
- "success" { Write-Host " success " -BackgroundColor Green -ForegroundColor White -NoNewline; }
- "information" { Write-Host " information " -BackgroundColor DarkCyan -ForegroundColor White -NoNewline; }
- "warning" { Write-Host " warning " -BackgroundColor DarkYellow -ForegroundColor White -NoNewline; }
- "error" { Write-Host " error " -BackgroundColor DarkRed -ForegroundColor White -NoNewline; }
- default { Write-Host " notes " -BackgroundColor DarkGray -ForegroundColor White -NoNewline; }
- }
- Write-Host (" {0}{1}" -f $message,$Global:blank)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement