$arch = ((systeminfo | findstr /C:"System Type") -replace 'System Type:\s*', '' -split '-')[0].Trim().ToLower() $ids = winget search Microsoft.VCRedist | Where-Object { $_ -match $arch } | ForEach-Object { [regex]::Match($_,'(Microsoft\.VCRedist\S+)').Value } $ids | ForEach-Object { winget install -e --id $_ }