Skip to content

Make PowerShell script invocation more reliable#46729

Open
flcdrg wants to merge 1 commit intomicrosoft:mainfrom
flcdrg:powershell-hardening
Open

Make PowerShell script invocation more reliable#46729
flcdrg wants to merge 1 commit intomicrosoft:mainfrom
flcdrg:powershell-hardening

Conversation

@flcdrg
Copy link
Copy Markdown

@flcdrg flcdrg commented Apr 2, 2026

Summary of the Pull Request

  • Protect against issues caused by loading PowerShell profile scripts
  • Ignore any warnings that may be generated by auto-loaded PowerShell modules. Warnings are written to stderr which the Exec then interprets as an error

PR Checklist

  • Communication: I've discussed this with core contributors already. If the work hasn't been agreed, this work might be rejected
  • Tests: Added/updated and all pass
  • Localization: All end-user-facing strings can be localized
  • Dev docs: Added/updated
  • New binaries: Added on the required places
  • Documentation updated: If checked, please file a pull request on our docs repo and link it here: #xxx

Detailed Description of the Pull Request / Additional comments

The build contains PowerShell invocations. The issue with these prior to this change is that they are vulnerable to what ever may be in the current user's PowerShell profile script.

They are also vulnerable to any auto-loaded PowerShell modules that may generate warnings, as the warning output is interpreted as an error by the MSBuild Exec task.

Validation Steps Performed

  1. Built successfully from command line and in Visual Studio
  2. Tested locally and also tested MouseWithoutBorders against second machine.

@flcdrg flcdrg force-pushed the powershell-hardening branch from 29c5aa8 to 1c9a591 Compare April 2, 2026 06:52
@flcdrg flcdrg marked this pull request as ready for review April 2, 2026 07:16
@flcdrg flcdrg force-pushed the powershell-hardening branch from 1c9a591 to d108e74 Compare April 3, 2026 06:04
- Protect against issues caused from loading default profile
- Ignore any warnings that may be generated by auto-loaded modules. Warnings are written to stderr which the Exec then interprets as an error

Fixes microsoft#46618
@flcdrg flcdrg force-pushed the powershell-hardening branch from d108e74 to 77eab34 Compare April 4, 2026 02:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Build fails with errors 'The command "powershell xxxxxx" exited with code 1'

1 participant