Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Example script showing auto-correction with DSC and PS7
Start-Job {
# path would need to be updated to where you have the FileContentResource.psm1 example saved
if ($env:PSModulePath -notlike "*demo*") {
$env:PSModulePath += [System.IO.Path]::PathSeparator + '/Users/steve/test/demo'
# temporarily ensure latest version required for this demo is loaded
Import-Module /Users/steve/test/demo/PSDesiredStateConfiguration -Force
$dscParams = @{
ModuleName = 'FileContentResource'
Name = 'FileContentResource'
Property = @{
filePath = '/Users/steve/test/demo/test.txt'
content = 'DSC Rocks!'
while ($true) {
if (!(Invoke-DscResource @dscParams -Method Test).InDesiredState) {
Invoke-DscResource @dscParams -Method Set
Start-Sleep -Seconds 10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment