This article is Part 4 in a 9-Part series about POSHOrigin, a PowerShell module that aims to assist you in managing your Infrastructure via custom PowerShell DSC resources.
- Part 1 - POSHOrigin - Summary
- Part 2 - POSHOrigin - Installation
- Part 3 - POSHOrigin - Configuration File
- Part 4 - POSHOrigin - Defaults File <<
- Part 5 - POSHOrigin - Load, Test, and Execute Configurations
- Part 6 - POSHOrigin - Sharing Configurations
- Part 7 - POSHOrigin - Credential Resolvers
- Part 8 - POSHOrigin - Examples
- Part 9 - POSHOrigin - Wrapping Up
Defaults File
The defaults file is where you can store common resource configuration data that will be shared across multiple configurations. When each resource block in your configuration is processed, if it specifies a defaults file, those defaults will be converted into a hashtable that will get merged with the hashtable of the resource. If there are any duplicates between the defaults file and the resource block, the values from the resource block will be used.
file_defaults.psd1
1
2
3
4
5
@{
ensure = 'present'
path = 'c:\'
contents = 'this is some content'
}
files.ps1
1
2
3
resource 'example:poshfile' 'file1.txt' @{
defaults = '.\file_defaults.psd1'
}
The examples above are the equivalent of specifying all options in the configuration file.
create_file.ps1
1
2
3
4
5
resource 'example:poshfile' 'file1.txt' @{
ensure = 'present'
path = 'c:\'
contents = 'this is some content'
}
Cheers