PowerShell / PowerShell/PowerShell
Start-ThreadJob doesn't honor switches or preference variables for Write-Debug, Write-Verbose, Write-Information
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 55.5k
- Forks
- 8.5k
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 88
Description
Prerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest released version
- Search the existing issues.
- Refer to the FAQ.
- Refer to Differences between Windows PowerShell 5.1 and PowerShell.
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 https://github.com/PowerShell/PowerShell/issues/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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the provided Start-ThreadJob script and compare its output with Start-Job, focusing on the InformationPreference, VerbosePreference, DebugPreference variables and the -InformationAction, -Verbose, and -Debug switches. Use the Start-ThreadJob and Receive-Job entry points, and review the related issue 24016. Done means the expected information, verbose, and debug output appears without requiring preferences to be set in the caller.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- shell
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100