microsoft / microsoft/winget-cli
`securityContext: elevated` does not have an effect with the PowerShell module
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
When using Invoke-WinGetConfiguration in Microsoft.WinGet.Configuration PowerShell module, the execution does not ask for elevation when securityContext: elevated is present in the configuration. Any module that requires elevation thus fails if the session is not run in elevated permissions manually
Steps to reproduce
- Install Microsoft.WinGet.Configuration PowerShell module
- Test against a
configuration.wingetfile like
# yaml-language-server: $schema=https://aka.ms/configuration-dsc-schema/0.2
properties:
resources:
- resource: Microsoft.Windows.Developer/DeveloperMode
directives:
description: Enable Developer Mode
# Only requires elevation for the set operation. To reproduce the issue
# make sure developer mode is currently disabled
securityContext: elevated
allowPrerelease: true
settings:
Ensure: Present
configurationVersion: 0.2.0
Microsoft.Windows.Developer/DeveloperMode requires elevation only for SET, so to reproduce make sure developer mode is currently disabled
- Run
Get-WinGetConfiguration -File configuration.winget | Invoke-WinGetConfiguration
Expected behavior
Configuration asks for UAC, applies desired state and returns with a success code
Actual behavior
Does not ask with UAC and since the config requires admin, it fails with an error code. If I elevate manually with sudo, the configuration applies the desired state successfully
Environment
~ Get-Module Microsoft.WinGet.Configuration | Select Version
Version
-------
1.10.340
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 issue with Invoke-WinGetConfiguration and the provided configuration.winget file, using Microsoft.WinGet.Configuration 1.10.340 and the Microsoft.Windows.Developer/DeveloperMode resource. Trace how the PowerShell module handles securityContext: elevated during the SET operation; done means an unelevated session prompts for UAC and applies the configuration successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- powershell
- Domain
- cli, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100