ms.date | ms.topic | keywords | title |
---|---|---|---|
06/12/2017 |
conceptual |
dsc,powershell,configuration,setup |
DSC Log Resource |
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[]] ]
}
NOTE: By default only the Operational logs for DSC are enabled. Before the Analytic log will be available or visible, it must be enabled. See the following article.
Property | Description |
---|---|
Message | Indicates the message you want to write to the Microsoft-Windows-Desired State Configuration/Analytic event log. |
DependsOn | Indicates 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" . |
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.
Configuration logResourceTest
{
Import-DscResource -ModuleName PSDesiredStateConfiguration
Node localhost
{
Log LogExample
{
Message = "This message will appear in the Microsoft-Windows-Desired State Configuration/Analytic event log."
}
}
}