Skip to content
This repository has been archived by the owner on Jan 7, 2023. It is now read-only.

WriteLog Environment Variable

Raymond Piller edited this page Aug 12, 2015 · 1 revision

The name of the environment variable is: Write-Log

This environment variable stores configuration settings for the Write-Log function. Any parameters passed to Write-Log will overwrite the settings in this environment variable.

Set the Write-Log environment variable like this:

PS > ${env:Write-Log} = ConvertTo-Json @{'LogFileDirectory'=$env:Temp; 'LogFileName'='Test.log'} -Compress

Access the Write-Log environment variable like this:

PS > ${env:Write-Log}
{"LogFileName":"Test.log","LogFileDirectory":"C:\\Users\\euid0123\\AppData\\Local\\Temp"}

The curly brackets {} are required to instantiate the beginning and end of the variable for PowerShell. The following will not work; you will get an error, as shown:

PS > $env:Write-Log
At line:1 char:11
+ $env:Write-Log
+           ~~~~
Unexpected token '-Log' in expression or statement.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : UnexpectedToken

Examples

For lots of examples, of using/setting this variable, have a look at the second half of the Write-Log.Tests.ps1 file.

Clone this wiki locally