Skip to content

Start-ThreadJob doesn't honor switches or preference variables for Write-Debug, Write-Verbose, Write-Information #26376

@jimAtLoyal

Description

@jimAtLoyal

Prerequisites

Steps to reproduce

Start-ThreadJob doesn't produce output for Information, Verbose, Debug in most cases. Here's a trivial test

Start-ThreadJob -ScriptBlock {
    $InformationPreference='Continue'
    $VerbosePreference='Continue'
    $DebugPreference='Continue'
    
    Write-Host "Starting test"

    Write-Information "Write-Information -InformationAction Continue" -InformationAction Continue
    Write-Information "Write-Information"

    Write-Verbose "Write-Verbose -Verbose" -Verbose
    Write-Verbose "Write-Verbose"

    Write-Debug "Write-Debug -Debug" -Debug
    Write-Debug "Write-Debug"
} | Receive-Job -Wait -AutoRemoveJob

Using Start-Job works. It appears to be that the thread job will only use the preferences variable from the caller, but ignore ones within the script or the switches.

The workaround is to set variables in the calling instance before calling Start-ThreadJob

$InformationPreference='Continue'
$VerbosePreference='Continue'
$DebugPreference='Continue'
Start-ThreadJob ...

This may be related to #24016

Expected behavior

Starting test
Write-Information -InformationAction Continue
Write-Information
VERBOSE: Write-Verbose -Verbose
VERBOSE: Write-Verbose
DEBUG: Write-Debug -Debug
DEBUG: Write-Debug

Actual behavior

Starting test

Error details

Environment data

Name                           Value
----                           -----
PSVersion                      7.5.4
PSEdition                      Core
GitCommitId                    7.5.4
OS                             Darwin 24.6.0 Darwin Kernel Version 24.6.0: Mon Jul 14 11:30:29 PDT 2025; root:xnu-11417.140.69~1/RELEASE_ARM64_T6000
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visuals

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs-TriageThe issue is new and needs to be triaged by a work group.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions