Table of contents
TOC
Collapse the table of content
Expand the table of content

DSC Log Resource

Eric Slesar|Last Updated: 5/16/2016
|
1 Contributor

Applies To: Windows PowerShell 4.0, Windows PowerShell 5.0

The Log resource in Windows PowerShell Desired State Configuration (DSC) provides a mechanism to write messages to the Microsoft-Windows-Desired State Configuration/Analytic event log.

Syntax

Log [string] #ResourceName
{
    Message = [string]
    [ DependsOn = [string[]] ]
}

Properties

PropertyDescription
MessageIndicates the message you want to write to the Microsoft-Windows-Desired State Configuration/Analytic event log.
DependsOnIndicates that the configuration of another resource must run before this log message gets written. For example, if the ID of the resource configuration script block that you want to run first is ResourceName and its type is ResourceType, the syntax for using this property is DependsOn = "[ResourceType]ResourceName".

Example

The following example shows how to include a message in the Microsoft-Windows-Desired State Configuration/Analytic event log.

Note: if you run Test-DscConfiguration with this resource configured, it will always return $false.

Log LogExample
{
    Message = "This message will appear in the Microsoft-Windows-Desired State Configuration/Analytic event log."
}
© 2016 Microsoft