-
Notifications
You must be signed in to change notification settings - Fork 56
Closed
Labels
Description
Prerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest version
- Search the existing issues.
Summary
I am experience a strange problem whenever I tried executing the Microsoft.DSC/PowerShell resource. I have the following file winget_dsc.config.yml modified from the examples:
$schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/config/document.json
parameters:
ensure:
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
Ensure: "[parameters('ensure')]"When I execute it, I get the following error message:
Steps to reproduce
- Use Install-Module -Name Microsoft.WinGet.DSC -Scope AllUsers and Install-PSResource -Name Microsoft.WinGet.DSC -Scope AllUsers
- Create the YAML configuration file in the description above
- Execute
dsc config set --path winget_dsc.config.yaml
Expected behavior
I would have expected the cache refreshing to filter out the latest DSC module it tries to return in the following lines:
foreach ($member in $typeDefinitionAst.Members) {
$property = $member -as [System.Management.Automation.Language.PropertyMemberAst]
if (($property -eq $null) -or ($property.IsStatic)) {
continue;
}
$skipProperty = $true
$isKeyProperty = $false
foreach ($attr in $property.Attributes) {
if ($attr.TypeName.Name -eq 'DscProperty') {
$skipProperty = $false
foreach ($attrArg in $attr.NamedArguments) {
if ($attrArg.ArgumentName -eq 'Key') {
$isKeyProperty = $true
}
}
}
}
if ($skipProperty) {
continue;
}
[DscResourcePropertyInfo]$prop = [DscResourcePropertyInfo]::new()
$prop.Name = $property.Name
$prop.PropertyType = $property.PropertyType.TypeName.Name
$prop.IsMandatory = $isKeyProperty
$DscResourceInfo.Properties.Add($prop)
}
$resourceList.Add($DscResourceInfo)Actual behavior
Throws an error if multiple modules are available.Error details
No response
Environment data
Name Value
---- -----
PSVersion 7.4.1
PSEdition Core
GitCommitId 7.4.1
OS Microsoft Windows 10.0.19045
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0Version
3.0.0-preview.8
Visuals
No response
