Skip to content

Commit 91bc422

Browse files
author
Steve Lee (POWERSHELL HE/HIM) (from Dev Box)
committed
add example config
1 parent d4981e3 commit 91bc422

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

dsc/examples/psscript.dsc.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Example configuration mixing native app resources with classic PS resources
2+
$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
3+
resources:
4+
- name: Use PS script
5+
type: Microsoft.DSC.Transitional/PowerShellScript
6+
properties:
7+
getScript: |
8+
Write-Warning "This is a warning message"
9+
# any output will be collected and returned
10+
$PSVersionTable

resources/PSScript/psscript.tests.ps1

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,4 +255,13 @@ Describe 'Tests for PSScript resource' {
255255
$result.actualState.output.Count | Should -Be 0 -Because ($result | ConvertTo-Json | Out-String)
256256
(Get-Content $TestDrive/error.txt -Raw) | Should -BeLike '*ERROR*:*This is an exception*'
257257
}
258+
259+
It 'Sample config works' {
260+
$configPath = Join-Path $PSScriptRoot '../../dsc/examples/psscript.dsc.yaml'
261+
$result = dsc config get -f $configPath 2> $TestDrive/error.txt | ConvertFrom-Json -Depth 10
262+
$LASTEXITCODE | Should -Be 0 -Because (Get-Content $TestDrive/error.txt -Raw | Out-String)
263+
$result.results[0].result.actualState.output.Count | Should -Be 1 -Because ($result | ConvertTo-Json -Depth 10 | Out-String)
264+
$result.results[0].result.actualState.output[0].PSEdition | Should -BeExactly 'Core'
265+
$result.results[0].result.actualState.output[0].PSVersion.Major | Should -Be 7
266+
}
258267
}

0 commit comments

Comments
 (0)