Skip to content

Replace deprecated wmic with PowerShell Get-ItemProperty in VsTest tasks (Issue #21123) #21129

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

sidshehria
Copy link

Summary

This PR fixes the issue where VsTest tasks fail on modern Windows systems due to using the deprecated wmic command.

Changes

  • Replace wmic command with PowerShell Get-ItemProperty cmdlet in VsTestV2 and VsTestV3
  • Update version parsing logic to handle direct version output from PowerShell
  • Add error handling with try-catch in PowerShell command
  • Improve version validation to accept minimum 3-part version numbers

Why This Change is Needed

  • wmic has been officially deprecated since Windows 10 21H1
  • wmic is no longer available on newer Windows systems including Server 2025
  • This causes VsTest tasks to fail with "Unable to locate executable file: 'wmic'" error
  • PowerShell Get-ItemProperty is the recommended modern alternative

Testing

  • Tested the PowerShell command manually on Windows systems
  • Verified that the new approach returns the same version information format
  • Confirmed error handling works properly for invalid file paths

Impact

  • Compatibility: Works on all Windows systems with PowerShell (virtually all modern Windows)
  • Reliability: More robust error handling and execution
  • Performance: Similar performance characteristics to the original implementation
  • Backward Compatibility: Maintains the same API and behavior for calling code

Fixes: Issue with VsTest tasks failing on systems without wmic

…emProperty in VsTest tasks

- Replace wmic command with PowerShell Get-ItemProperty cmdlet in VsTestV2 and VsTestV3
- wmic has been deprecated since Windows 10 21H1 and is no longer available on newer systems
- PowerShell approach is more reliable and supported on modern Windows systems
- Updated version parsing logic to handle direct version output from PowerShell
- Added error handling with try-catch in PowerShell command
- Fixes issue where VsTest tasks fail on systems without wmic

Resolves: Azure DevOps Tasks issue with wmic deprecation
@sidshehria
Copy link
Author

I have sole ownership of intellectual property rights to my Submissions and I am not making Submissions in the course of work for my employer.

@sidshehria
Copy link
Author

@microsoft-github-policy-service agree

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.

1 participant