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?

Open
#4,838 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Area-External Issue-Bug
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.