This article is Part 3 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
Configuration File
The POSHOrigin configuration file is where you define your resources to be evaluated by POSHOrigin. These configuration files will be read and translated into DSC configurations that get applied either to your local machine, or to a provisioning machine in order to provision infrastructure.
You define your resources in the configuration file by adding a resource block for each resource you want to provision.
my_folder.ps1
1
2
3
4
5
resource 'example:poshfolder' 'folder01' @{
description = 'this is an example folder'
ensure = 'present'
path = 'c:\'
}
Defining multiple resources in the same file is supported as well.
create_folders.ps1
1
2
3
4
5
6
7
8
9
10
11
resource 'example:poshfolder' 'folder01' @{
description = 'this is an example folder'
ensure = 'present'
path = 'c:\'
}
resource 'example:poshfolder' 'folder02' @{
description = 'this is another example folder'
ensure = 'present'
path = 'c:\'
}
The resource function is really an alias for the function New-POSHOriginResource that has three required parameters:
The resource function will evaluate the parameters given to it, merge default options if specified, resolve any secrets listed into PowerShell credentials, and return one or more PowerShell custom objects. When you run Get-POSHOriginConfig (or gpoc) against a configuration file or folder, the resultant collection of PowerShell custom objects will be returned back to you. This array of objects can then be converted into a DSC configuration by passing them to Invoke-POSHOrigin or (ipo).
1
2
$myConfigs = Get-POSHOriginConfig -Path .\myFolder.ps1 -Verbose
$myConfigs | Invoke-POSHOrigin -Verbose
Cheers