PowerShell / PackageManagementProviderResource

Modules with DSC resources for the PackageManagement(aka OneGet) providers.
MIT License
37 stars 24 forks source link

Scope property for Machine vs User #45

Open kfsone opened 1 year ago

kfsone commented 1 year ago

Summary of the new feature / enhancement

PackageManagementResource can install Winget and drive that, but it is nearly impossible to use meaningfully for two reasons:

1- winget install accepts a "--scope" parameter to let you specify whether the package is per-user or machine-wide, but PackageManager does not surface this,

2- attempting to instead pass the PSCredential of the user it should be installed as via PsDscRunAsCredential consistently produces an 0x80070520 error (no logon session) unless it is the credential of the current user anyway (which is thus pointless).

Proposed technical implementation details (optional)

Configuration InstallTerminal
{
  Param([Parameter(Mandatory)][PSCredential] $UserCred)

  PackageManager Winget
  {
    Name = 'WinGet'
    Source = 'PSGallery'
  }

  PackageManager WindowsTerminal
  {
    DependsOn = '[PackageManager]Winget'
    Ensure = 'Present'
    Name = 'Microsoft.WindowsTerminal'
    RequiredVersion = 'latest'
    ProviderName = 'WinGet'

    # New
    Scope = 'LocalMachine'  # vs PsDscRunAsCredential $UserCred -> 0x80070520
  } 
}