Data Files as Script Files
Last year, I wrote an article about the importance of separating PowerShell code from the data you need to run that code. I still believe this is a critical distinction many PowerShell beginners overlook. I want to revisit one of the topics from that article, and that is about using configuration data.
Think of configuration data as a structured way to present values that can be consumed by a PowerShell expression. For our purposes, configuration data is stored as a hash table.
$data = @{
LogName = 'System'
Properties = @('ID', 'Message', 'MachineName', 'ProviderName', 'TimeCreated', 'LevelDisplayName')
Filter = '*[System[Level=2 or Level=3]]'
}
My PowerShell script can use the data like this:
Want to read the full issue?