TrainingUtils.CSCN.psm1
function Show-Log { [CmdletBinding()] param( [Parameter(Mandatory=$true)] [ValidateSet("INFO", "WARNING", "ERROR", "DEBUG", "VERBOSE")] [string]$Type, [Parameter(Mandatory=$true)] [string]$Message ) $TimeStamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss" $LogMessage = "[$TimeStamp] [$Type]: $Message" Write-Verbose "Verbose output" Write-Debug "Debug output" Write-Host $LogMessage } function Write-Log { [CmdletBinding()] param( [Parameter(Mandatory=$true)] [ValidateSet("INFO", "WARNING", "ERROR", "DEBUG", "VERBOSE")] [string]$Type, [Parameter(Mandatory=$true)] [string]$Message, [Parameter(Mandatory=$true)] [string]$LogFilePath ) $TimeStamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss" $LogMessage = "Verbose output" + "`nDebug output" + "`n[$TimeStamp] [$Type]: $Message" Save-LogToFile -LogMessage $LogMessage -LogFilePath $LogFilePath } function Save-LogToFile { [CmdletBinding()] param( [Parameter(Mandatory=$true)] [string]$LogMessage, [Parameter(Mandatory=$true)] [string]$LogFilePath ) Add-Content -Path $LogFilePath -Value $LogMessage } |