Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add example configs for winget and wmi #453

Merged
merged 15 commits into from
Jul 3, 2024
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
Loading