Examples/Demo1.ps1
cls configuration Demo1 { Import-DscResource -module xjea xJeaEndPoint DemoEP { Name = 'Demo1EP' Toolkit = 'Demo1Toolkit' } script pause { GetScript = {return @{}} SetScript = {return} TestScript = {Start-Sleep -seconds 5; return $true} } xJeaToolKit Demo1Toolkit { Name = 'Demo1Toolkit' CommandSpecs = @" name Get-Process Get-Service "@ DependsOn = '[Script]Pause' } } Demo1 -OutputPath C:\DSCDemo Write-Host @" ******************************************************************************** This first pass of this script is designed to fail (by trying to create an endpoint before the toolkit is ready). We do this to illustrate the nature of convergence. Every time DSC runs, it skips the things that are in the correct state and tries to fix the things that aren't in the correct state. ******************************************************************************** "@ Start-DscConfiguration -Path C:\DSCDemo -ComputerName localhost -Verbose -wait write-host @" ******************************************************************************** Now we do a Get and notice that it doesn't show much in the converge state ******************************************************************************** "@ Get-DscConfiguration Write-Host @" ******************************************************************************** This is the second pass of this script and now everything should work. Read the VERBOSE messages and notice the lines that contain this: LCM: [ Skip Set ] Those are the resources that are already in the Desired State ******************************************************************************** "@ Start-DscConfiguration -Path C:\DSCDemo -ComputerName localhost -Verbose -wait write-host @" ******************************************************************************** Now we do a Get and get all the components with the right Desired State Configuration ******************************************************************************** "@ Get-DscConfiguration | % {$_.pstypenames[0]; $_} start-sleep -Seconds 10 #Wait for WINRM to restart $s = New-PSSession -cn . -ConfigurationName demo1EP Invoke-command $s {get-command} |out-string |