Last active
March 27, 2021 01:09
-
-
Save SteveL-MSFT/f4a794f5002c2e06d2e99dff447896ef to your computer and use it in GitHub Desktop.
Example script showing auto-correction with DSC and PS7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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