Skip to content

Commit

Permalink
Merge pull request #453 from SteveL-MSFT/psconfeu
Browse files Browse the repository at this point in the history
Add example configs for winget and wmi
  • Loading branch information
SteveL-MSFT authored Jul 3, 2024
2 parents b0e6ed9 + 773cd8d commit 8c0f2f0
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 1 deletion.
4 changes: 4 additions & 0 deletions dsc/examples/osinfo_parameters.dsc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@ resources:
type: Microsoft/OSInfo
properties:
family: macOS
- name: path
type: Test/Echo
properties:
output: "[envvar('PATH')]"
24 changes: 24 additions & 0 deletions dsc/examples/winget.dsc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# The `Microsoft.Winget.DSC` resources needs to be installed: install-psresource Microsoft.Winget.DSC -Prerelease

$schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/config/document.json
parameters:
ensureCalc:
type: string
defaultValue: Present
allowedValues:
- Present
- Absent
resources:
- name: Use class PowerShell resources
type: Microsoft.DSC/PowerShell
properties:
resources:
- name: PowerShell 7 Preview
type: Microsoft.WinGet.DSC/WinGetPackage
properties:
Id: Microsoft.PowerShell.Preview
- name: Calc from Windows Store
type: Microsoft.WinGet.DSC/WinGetPackage
properties:
Id: "9WZDNCRFHVN5"
Ensure: "[parameters('ensureCalc')]"
10 changes: 10 additions & 0 deletions dsc/examples/wmi.dsc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
$schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/config/document.json
resources:
- name: WMI
type: Microsoft.Windows/WMI
properties:
resources:
- name: computer system
type: root.cimv2/Win32_ComputerSystem
- name: network adapter
type: root.cimv2/Win32_NetworkAdapter
10 changes: 10 additions & 0 deletions wmi-adapter/Tests/wmi.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,14 @@ Describe 'WMI adapter resource tests' {
$res.results[0].result.actualState[1].BiosCharacteristics | Should -Not -BeNull
$res.results[0].result.actualState[2].NumberOfLogicalProcessors | Should -Not -BeNull
}

It 'Example config works' -Skip:(!$IsWindows) {
$configPath = Join-Path $PSScriptRoot '..\..\dsc\examples\wmi.dsc.yaml'
$r = dsc config get -p $configPath
$LASTEXITCODE | Should -Be 0
$r | Should -Not -BeNullOrEmpty
$res = $r | ConvertFrom-Json
$res.results[0].result.actualState[0].Model | Should -Not -BeNullOrEmpty
$res.results[0].result.actualState[1].Description | Should -Not -BeNullOrEmpty
}
}
2 changes: 1 addition & 1 deletion wmi-adapter/copy_files.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
wmi.resource.ps1
wmi.dsc.resource.json.optout
wmi.dsc.resource.json

0 comments on commit 8c0f2f0

Please sign in to comment.