Set-EventDebug.ps1

function Set-EventDebug
{
  <#
      .SYNOPSIS
      Set the debug level
      .DESCRIPTION
      If set to $true (default is $false) then every information or error message is recorded individualy in the eventlog "RMMScript"
      If set to $false (default) thenall messages are recorded in a final event in the eventlog "RMMScript"
      .EXAMPLE
      Set-Debug $true
  #>

  [CmdletBinding()]
  param
  (
    [Parameter(Mandatory=$false, Position=0)]
    [System.Object]
    $debugParam = $false
  )
  
  $global:debug = $debugParam
}