Skip to content
This repository was archived by the owner on Jun 14, 2024. It is now read-only.
This repository was archived by the owner on Jun 14, 2024. It is now read-only.

WindowsOptionalFeature: Get Method fails if OptionalFeature has no custom properties when called by the LCM. #191

@jambar42

Description

@jambar42

When the WindowsOptionalFeature DSC resource Get method is invoked by the LCM, an error is thrown if the Optional Feature has no custom properties.

Optional Feature with Custom Properties:
PS C:\Windows\system32> Invoke-DscResource -Name "WindowsOptionalFeature" -Method Get -ModuleName "PSDSCResources" -Property @{Name = "SystemDataArchiver"; Ensure = 'Present'}

ConfigurationName :
DependsOn :
ModuleName : PSDSCResources
ModuleVersion : 2.9.0.0
PsDscRunAsCredential :
ResourceId :
SourceInfo :
CustomProperties : {Name = Description, Value = Provides services to collect and archive Windows Server system
data., Path = ServerComponent, Name = DisplayName, Value = System Data Archiver, Path =
ServerComponent, Name = Id, Value = 1043, Path = ServerComponent, Name = Type, Value = Feature,
Path = ServerComponent...}
Description : Provides services to collect and archive Windows Server system data.
DisplayName : System Data Archiver
Ensure : Present
LogLevel : WarningsInfo
LogPath : C:\Windows\Logs\DISM\dism.log
Name : SystemDataArchiver
NoWindowsUpdateCheck :
RemoveFilesOnDisable :
PSComputerName : localhost
BeforeChangeWithCustomProperties

Optional Feature without Custom Properties:
PS C:\Windows\system32> Invoke-DscResource -Name "WindowsOptionalFeature" -Method Get -ModuleName "PSDSCResources" -Property @{Name = "HypervisorPlatform"; Ensure = 'Present'}
A general error occurred that is not covered by a more specific error code.
+ CategoryInfo : NotSpecified: (root/Microsoft/...gurationManager:String) [], CimException
+ FullyQualifiedErrorId : MI RESULT 1
+ PSComputerName : localhost
BeforeChangeWithoutCustomProperties

Windows\Desired State Configuration Event Error 4250 thrown:
Job {FCA666F0-D06E-11EA-AD33-248A07A40AF1} :
Message Specified cast is not valid.
HResult -2147467262
StackTrack at Microsoft.PowerShell.DesiredStateConfiguration.Internal.DownloadManagerBase.ConvertCimInstanceToHashTable(CimInstance cimInstance, Boolean bWrap)
at Microsoft.PowerShell.DesiredStateConfiguration.Internal.DownloadManagerBase.ConvertCimInstanceToHashTable(CimInstance cimInstance, Boolean bWrap)
at Microsoft.PowerShell.DesiredStateConfiguration.Internal.DownloadManagerBase.ConvertCimInstanceToHashTable(CimInstance cimInstance, Boolean bWrap)
at Microsoft.PowerShell.DesiredStateConfiguration.Internal.DownloadManagerBase.GetJsonStringArrayStatusValue(Object value, IntPtr& statusInstanceHandle, UInt32& getActionStatusCode)
at Microsoft.PowerShell.DesiredStateConfiguration.Internal.DownloadManagerBase.AddSendStatusParametersFromStatusInformation(PowerShell powershell, IntPtr statusInformationPtr, UInt32 reportType, IntPtr& errorInstanceHandle, UInt32& getActionStatusCode)
at Microsoft.PowerShell.DesiredStateConfiguration.Internal.DownloadManagerBase.SendStatusReport(IntPtr metaConfigHandle, IntPtr& errorInstanceHandle, IntPtr statusInformation, UInt32 reportType, UInt32& getActionStatusCode)
DSCEvent4250

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions