Open
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 experiencing a problem with how output (for example a warning from Write-Warning
) are handled during module import. I think any output to output streams should be handled correctly and not interrupt the resource parsing process. But actually, such output (like warnings) are being interpreted as output and included in the parsing of results, causing DSC to fail parsing the result from Get operation.
This could be related to (or resolved by) issue #423 and #788. It also looks like this issue is related to issue #261.
Steps to reproduce
- Install latest module SqlServerDsc (that include the class-based resource) into the correct folder
- Run the following:
$desiredParameters = @{ InstanceName = 'PBIRS' AcceptLicensingTerms = $true Action = 'Install' MediaPath = '<Path to any existing executable on local machine>' InstallFolder = [System.IO.Path]::GetTempPath() Edition = 'Developer' SuppressRestart = $true VersionUpgrade = $true } dsc --trace-level trace resource get --resource SqlServerDsc/SqlRSSetup --output-format pretty-json --input ($desiredParameters | ConvertTo-Json -Compress)
- Watch the error
407: Failed to parse resource
where it includes an output fromWrite-Warning
that the SqlServerDsc module output during module import.
Expected behavior
DSC executable should parse the result from a Get operation regardless what is output on output streams.
Actual behavior
Fails to parse the result becuase it includes the warning stream.
Error details
2025-05-23T05:27:02.114426Z WARN dsc_lib::discovery::command_discovery: 407: Failed to parse resource: WARNING: Failed to find a dependent module. Unable to run SQL Server commands or use SQL Server types. Please install -> expected value at line 1 column 1
2025-05-23T05:27:02.114443Z WARN dsc_lib::discovery::command_discovery: 407: Failed to parse resource: one of the preferred SMO modules or the SQLPS module, then try to import SqlServerDsc again. -> expected value at line 1 column 1
...
2025-05-23T05:27:43.375232Z ERROR dsc::resource_command: 44: Error: Operation: Failed to parse JSON from 'get': executable = 'powershell' stdout = 'WARNING: Failed to find a dependent module. Unable to run SQL Server commands or use SQL Server types. Please install
one of the preferred SMO modules or the SQLPS module, then try to import SqlServerDsc again.
{"result":[{"name":"SqlServerDsc/SqlRSSetup","type":"SqlServerDsc/SqlRSSetup","properties":{"Timeout":7200,"InstanceName":"","Action":0,"AcceptLicensingTerms":false,"MediaPath":null,"ProductKey":null,"EditionUpgrade":null,"Edition":null,"LogPath":null,"InstallFolder":"","SuppressRestart":null,"ForceRestart":null,"VersionUpgrade":null,"localizedData":{"MediaPath_Invalid":"The media path '{0}' does not exist. (SRSS0006)","Uninstalling_ReportingServices":"Uninstalling SQL Server Reporting Services. (SRSS0016)","TestDesiredState":"Determining the current state for resource '{0}' using the key property '{1}'. (RB0002)","NotDesiredProductVersion":"The product version '{0}' is not the desired for the instance '{1}'. Desired version in executable: '{2}'. (SRSS0018)","InDesiredState":"The current state is the desired state. (RB0005)","Instance_Installed":"Instance '{0}' is installed. (SRSS0004)","Repairing_ReportingServices":"Repairing SQL Server Reporting Services. (SRSS0014)","EditionOrProductKeyMissing":"Neither the parameters Edition or ProductKey was specified. (SRSS0008)","Installing_ReportingServices":"Installing SQL Server Reporting Services. (SRSS0012)","Instance_NotInstalled":"Instance '{0}' is not installed. (SRSS0003)","ModifyMethodNotImplemented":"An override for the method Modify() is not implemented in the resource. (RB0008)","Getting_Information_Instance":"Getting information about instance '{0}'. (SRSS0002)","MediaPath_DoesNotHaveRequiredExtension":"The media path '{0}' does not reference an executable with the required extension .exe. (SRSS0007)","EditionUpgrade_RequiresKeyOrEdition":"EditionUpgrade requires either ProductKey or Edition to be specified. (SRSS0009)","CannotDetermineEdition":"Could not determine the edition for the installed instance '{0}'. Run the command `Get-SqlDscRSSetupConfiguration -InstanceName '{0}'` to get the configuration for the instance and verify that it returns a valid edition. (SRSS0021)","NoPropertiesToSet":"All properties are in desired state. (RB0007)","InstanceName_Invalid":"The instance name '{0}' is invalid. Only one of the supported instance name can be used, either SSRS or PBIRS depending on what setup executable is used. (SRSS0019)","LogPath_ParentMissing":"The parent directory '{0}' for LogPath does not exist. (SRSS0010)","NotInDesiredState":"The current state is not the desired state. (RB0004)","GetCurrentState":"Getting the current state for resource '{0}' using the key property '{1}'. (RB0001)","CannotDetermineProductVersion":"Could not determine the product version for the installed instance '{0}'. Run the command `Get-SqlDscRSSetupConfiguration -InstanceName '{0}'` to get the configuration for the instance and verify that it returns a valid product version. (SRSS0020)","Installing_PowerBIReportServer":"Installing Power BI Report Server. (SRSS0013)","NotDesiredEdition":"The edition '{0}' is not the desired for the instance '{1}'. Desired edition in executable: '{2}'. (SRSS0022)","SetProperty":"The property '{0}' will be set to '{1}'. (RB0006)","AcceptLicensingTerms_Required":"AcceptLicensingTerms must be set for Install and Repair operations. (SRSS0005)","GetCurrentStateMethodNotImplemented":"An override for the method GetCurrentState() is not implemented in the resource. (RB0009)","SetDesiredState":"Setting the desired state for resource '{0}' using the key property '{1}'. (RB0003)","Uninstalling_PowerBIReportServer":"Uninstalling Power BI Report Server. (SRSS0017)","Repairing_PowerBIReportServer":"Repairing Power BI Report Server. (SRSS0015)","InstallFolder_ParentMissing":"The parent directory '{0}' for InstallFolder does not exist. (SRSS0011)"},"ExcludeDscProperties":["Action","AcceptLicensingTerms","MediaPath","ProductKey","EditionUpgrade","Edition","LogPath","InstallFolder","SuppressRestart","Timeout","ForceRestart","VersionUpgrade"],"FeatureOptionalEnums":false}}]}'
stderr = '' -> expected value at line 1 column 1
Environment data
Name Value
---- -----
PSVersion 7.4.7
PSEdition Core
GitCommitId 7.4.7
OS Microsoft Windows 10.0.17763
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Version
3.1.0-preview.6
Visuals
No response