Write-Event.ps1
function Write-Event { <# .SYNOPSIS Add the text passed as a parameter into the $global:Output variable If $globel:Debug is defined also writes the text into an event into the log defined in $global:EventLog with event source set as defined in $global:EventSource and EntryType as INFORMATION and EventID 666 Get-StackIndent function is called to add some leading information about the script .EXAMPLE Write-Event "Some text" #> param ([Parameter(Mandatory=$true)][String]$Message=$Global:nl) $s = Get-StackIndent $global:Output += " $s$message<br>" + $Global:nl if ($global:debug) { Write-EventLog -LogName $global:EventLog -Source $global:EventSource -EntryType Information -EventID 666 -Message " $s$message" " $s$message" } } |