microsoft / microsoft/winget-cli
When running Get-WinGetPackage in a Windows Service context returns error This cmdlet is not supported in Windows PowerShell. However, if not ran in Service context, runs perfectly. Why?
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 26.4k
- Forks
- 1.8k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 15
Description
Brief description of your issue
I have a rust program that can run as a normal console program or as a Windows Service and I need to run this command "C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -Command { Get-WinGetPackage | ConvertTo-Json }".
When I run the rust program as a normal console program everything works perfectly and I get the data I need, as well as if I run that command directly in the console.
However, if I run that same rust program as a Windows Service it gives this error: Get-WinGetPackage: This cmdlet is not supported in Windows PowerShell.
It is using the same powershell path but I receive different responses. Why??
I have only tested this in a VM environment, i used Windows 11 Pro.
Thank you for your time.
Steps to reproduce
Create a rust program that executes this command "C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -Command { Get-WinGetPackage | ConvertTo-Json }", and run it as a normal console program and as a Windows Service.
Expected behavior
The command should return a json containing information about the winget packages (Get-WinGetPackage)
Actual behavior
The command returns this error:
Get-WinGetPackage: This cmdlet is not supported in Windows PowerShell.
Environment
Windows 11 Pro
Rust Program
Windows Service
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
Start by reproducing the exact powershell.exe command from the Rust program in both console and Windows Service contexts on Windows 11. Compare the execution environments and the Get-WinGetPackage behavior; done means explaining the differing result or identifying a documented repository change that resolves it.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- powershell, rust
- Domain
- cli, operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100