counter customizable

Logging for PowerShell

Here is a simple function or logging in PowerShell

 

# Settings for logging
$Logfile = "C:\Log\PowerShell-LogFile.log"
Function Write-Log
{
   Param ([string]$logstring)
   Add-content $Logfile -value $logstring
}

 

The just use the function Write-log like you would use Write-Host.

Write-Log "WDS Not Installed."

Mikael Karlsson posted at 2015-10-9 Category: PowerShell