Skip to content

dsc hangs up when used with task scheduler #1609

Description

@musklor

Prerequisites

  • Write a descriptive title.
  • Make sure you are able to repro it on the latest version
  • Search the existing issues.

Summary

Version : v3.3.0-preview.3
A big script for the SQL installation.
I use a scheduled task. This scheduled task launch dsc with a pwsh script.
With 3.2.2 version no problem at all.
With v3.3.0-preview.3 it is blocked but the sql installation is ok. Logs are ok.

Steps to reproduce

$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
parameters:
  myObject:
    type: object
resources:
- name: Use PS Script for KBs installation
  type: Microsoft.DSC.Transitional/PowerShellScript
  properties:
    input:
      object: "[parameters('myObject')]"
    getScript: |
      param($inputArray)
      $sqlInstances = gcim win32_service -computerName localhost | ? { $_.Name -match "mssql*" -and $_.PathName -match "sqlservr.exe" } | % { $_.Caption }
      $logErrors = if (Test-Path "c:\temp\MSSQLInstall_logs*") {
        Select-String -Path "c:\temp\MSSQLInstall_logs*" -Pattern "Save on error" -Quiet -NotMatch
      }
      $res = $sqlInstances -ne $null -and $sqlInstances -gt 0
      $vals = @{ 
        Installed = $res; 
        InstanceCount = $sqlInstances.count
        LogErrorsFound = $logErrors 
      }
      $vals
    testScript: |
      param($inputArray)
      $InformationPreference = "Continue"
      $sqlInstances = gcim win32_service -computerName localhost | ? { $_.Name -match "mssql*" -and $_.PathName -match "sqlservr.exe" } | % { $_.Caption }
      $logErrors = if (Test-Path "c:\temp\MSSQLInstall_logs*") {
        Select-String -Path "c:\temp\MSSQLInstall_logs*" -Pattern "Save on error" -Quiet
      }
      $res = $sqlInstances -ne $null -and $sqlInstances.Count -gt 0 -and $logErrors -ne $true
      if ($res) {
        Write-Information "SQL Server is already installed"
      } else {
        Write-Information "SQL Server is not installed"
      }
      $res
    setScript: |
# start-process setup.exe
#try catch
#start-transcript
#stop-transcript

Expected behavior

executionInformation:
  duration: PT6.405016S
  endDatetime: 2026-07-07T17:14:31.279880600+02:00
  executionType: actual
  operation: get
  securityContext: elevated
  startDatetime: 2026-07-07T17:14:24.874864600+02:00
  version: 3.3.0-preview.3
metadata:
  Microsoft.DSC:
    duration: PT6.4050011S
    endDatetime: 2026-07-07T17:14:31.279865700+02:00
    executionType: actual
    operation: get
    securityContext: elevated
    startDatetime: 2026-07-07T17:14:24.874864600+02:00
    version: 3.3.0-preview.3
results:
- executionInformation:
    duration: PT2.3129199S
  metadata:
    Microsoft.DSC:
      duration: PT2.3129199S
  name: Use PS Script for KBs installation
  type: Microsoft.DSC.Transitional/PowerShellScript
  result:
    actualState:
      output:
      - InstanceCount: 1
        Installed: true
        LogErrorsFound: null
messages: []
hadErrors: false

Actual behavior

2026-07-07T15:29:59.991957Z DEBUG dsc_lib::dscresources::dscresource: 405: Invoking get for 'Microsoft.DSC.Transitional/PowerShellScript'
2026-07-07T15:29:59.992007Z DEBUG dsc_lib::dscresources::command_resource: 40: Invoking get for 'Microsoft.DSC.Transitional/PowerShellScript'
2026-07-07T15:30:00.000446Z DEBUG dsc_lib::dscresources::command_resource: 1057: Parsing input as stdin
2026-07-07T15:30:00.000498Z  INFO dsc_lib::dscresources::command_resource: 59: Invoking get 'Microsoft.DSC.Transitional/PowerShellScript' using 'pwsh'
2026-07-07T15:30:02.655638Z  INFO dsc_lib::dscresources::command_resource: 1206: PID 3488: Perform operation 'Enumerate CimInstances' with following parameters, ''className' = win32_service,'namespaceName' = root\cimv2'.
2026-07-07T15:30:02.997544Z  INFO dsc_lib::dscresources::command_resource: 1206: PID 3488: Operation 'Enumerate CimInstances' complete.
2026-07-07T15:30:03.159854Z DEBUG dsc_lib::dscresources::command_resource: 813: Process 'pwsh' id 3488 exited with code 0
2026-07-07T15:30:03.160464Z DEBUG dsc_lib::dscresources::command_resource: 62: Verifying output of get 'Microsoft.DSC.Transitional/PowerShellScript' using 'pwsh'
{"executionInformation":{"duration":"PT7.4664298S","endDatetime":"2026-07-07T17:30:03.160818900+02:00","executionType":"actual","operation":"get","securityContext":"elevated","startDatetime":"2026-07-07T17:29:55.694389100+02:00","version":"3.3.0-preview.3"},"metadata":{"Microsoft.DSC":{"duration":"PT7.4664193S","endDatetime":"2026-07-07T17:30:03.160808400+02:00","executionType":"actual","operation":"get","securityContext":"elevated","startDatetime":"2026-07-07T17:29:55.694389100+02:00","version":"3.3.0-preview.3"}},"results":[{"executionInformation":{"duration":"PT3.1687751S"},"metadata":{"Microsoft.DSC":{"duration":"PT3.1687751S"}},"name":"Use PS Script for KBs installation","type":"Microsoft.DSC.Transitional/PowerShellScript","result":{"actualState":{"output":[{"Installed":true,"InstanceCount":1,"LogErrorsFound":true}]}}}],"messages":[],"hadErrors":false}

Error details

Environment data

Name                           Value
----                           -----
PSVersion                      7.4.14
PSEdition                      Core
GitCommitId                    7.4.14
OS                             Microsoft Windows 10.0.26100
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Version

3.3.0-preview.3

Visuals

No response

Metadata

Metadata

Assignees

Labels

Issue-BugSomething isn't workingNeed-ReviewWaiting on AuthorThe PR was reviewed and requires changes or comments from the author before being accept

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions