Forum Discussion

EPNAdam's avatar
EPNAdam
Brass Contributor
Nov 27, 2024
Solved

Winget in Remediation scripts

Does the remediation scripts and the execution envrionment support winget? Running this returns nothing:  $version = winget --version | Out-String   Have also tried to use the Start-Process app...
  • EPNAdam's avatar
    Nov 28, 2024

    Managed to get it working.

    # Find the path to winget.exe
    $winget = Get-ChildItem "C:\Program Files\WindowsApps\" -Recurse -File | Where-Object { $_.Name -eq 'winget.exe' } | Select-Object -ExpandProperty FullName -First 1
           
    if($winget) {
      Write-Host "- Found winget.exe at: $winget"         
      Write-Host "- Checking winget version"
      $wingetVersion = & "$winget" --version
       Write-Host "Winget version: $wingetVersion"
    }

     

Resources