My Profile Photo Title

Thoughts about DevOps and automation from a Windows guy


POSHOrigin - Load, Test, and Execute Configurations feature image

POSHOrigin - Load, Test, and Execute Configurations

This article is Part 5 in a 9-Part series about POSHOrigin, a PowerShell module that aims to assist you in managing your Infrastructure via custom PowerShell DSC resources.

POSHOrigin on GitHub→

Loading Configurations

You load POSHOrigin configurations by calling the Get-POSHOriginConfig function and specifying the file, files, or folder to process. You can recursively process subfolders as well. Get-POSHOriginConfig returns one or more custom objects that can then be converted into DSC configurations.

$myConfig = Get-POSHOriginConfig -Path '.\myFolder.ps1' -Verbose
$myConfigs = '.\myfile1.ps1', 'myfile2.ps1' | Get-POSHOriginConfig -Verbose
$myConfigs = Get-POSHOriginConfig -Path . -Recurse -Verbose

Testing Configurations

You can test your infrastructure for compliance against your configuration by calling the Invoke-POSHOrigin function with the -WhatIf switch. Internally, POSHOrigin will execute the Test-DscConfiguration DSC cmdlet against the MOF file that is compiled.

NO RESOURCES WILL BE CREATED, DELETED, OR MODIFIED when using the -WhatIf switch.

1
2
3
$myConfig = Get-POSHOriginConfig -Path '.\vm_config.ps1' -Verbose
Invoke-POSHOrigin -ConfigData $myConfig -Verbose -WhatIf
Get-POSHOriginConfig -Path '.\vm_config.ps1' -Verbose | Invoke-POSHOrigin -Verbose -WhatIf

Executing Configurations

You can execute your POSHOrigin configuration by calling the Invoke-POSHOrigin function. Internally, POSHOrigin will execute the Start-DscConfiguration DSC cmdlet against the MOF file that is compiled.

RESOURCES WILL BE CREATED, DELETED, OR MODIFIED. You should run Invoke-POSHOrigin with the -WhatIf prior to this in order to get an idea of changes will occur.

1
2
$myConfig = Get-POSHOriginConfig -Path '.\vm_config.ps1' -Verbose
Invoke-POSHOrigin -ConfigData $myConfig -Verbose

Cheers

Show your support

Become a GitHub Sponsor
Become a Patron

Like books? Check these out!

You might also like:

Sharing is caring