-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Open
Labels
Needs-TriageThe issue is new and needs to be triaged by a work group.The issue is new and needs to be triaged by a work group.Waiting on AuthorThe PR was reviewed and requires changes or comments from the author before being acceptThe PR was reviewed and requires changes or comments from the author before being accept
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
- Make sure to have a WSL named "NewDistro" with a user "nico" that can run sudo without password or adjust the distro/user in the code below.
- Run the sample program:
powershell.exe -ExecutionPolicy Bypass -File ".\Powershell-class-bug.ps1"
- Observe that sudo prompts appear twice for class methods, once for functions
- This affects any external process execution, not just WSL/sudo
- Commands that modify state will execute their changes twice
Impact: This duplicate execution causes multiple serious issues:
- Interactive commands prompt for input twice (passwords, confirmations)
- Commands with side effects execute twice (file creation, database operations)
- Performance degradation due to unnecessary duplicate operations
- Inconsistent behavior between class methods and regular functions
- Makes class-based architectures unreliable for external process automation
Expected behavior
Class methods and functions should execute external commands identically
Actual behavior
Class instance methods execute external commands twice
Error details
Run sample program
Environment data
- PowerShell Version:7.5.3
- PowerShell Version: 5.1.26100.6584
- OS: Microsoft Windows NT 10.0.26100.0
- WSL Version:
- WSL-versie: 2.4.13.0
- Kernelversie: 5.15.167.4-1
- WSLg-versie: 1.0.65
- MSRDC-versie: 1.2.5716
- Direct3D-versie: 1.611.1-81528511
- DXCore-versie: 10.0.26100.1-240331-1435.ge-release
- Windows-versie: 10.0.26100.6584
Visuals
Metadata
Metadata
Assignees
Labels
Needs-TriageThe issue is new and needs to be triaged by a work group.The issue is new and needs to be triaged by a work group.Waiting on AuthorThe PR was reviewed and requires changes or comments from the author before being acceptThe PR was reviewed and requires changes or comments from the author before being accept