Forum Discussion
EPNAdam
Nov 27, 2024Brass Contributor
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 approach:
# Define the path to winget.exe
$WingetPath = "C:\Program Files\WindowsApps\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\winget.exe"
Start-Process -FilePath $WingetPath....
Is it even possible to get winget working in detection- and remediation scripts?
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" }
- EPNAdamBrass Contributor
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" }